Forums › Forums › SIMPOL Programming › focuscontrol
- This topic has 6 replies, 2 voices, and was last updated 11 years ago by Jean Vallee.
- AuthorPosts
- April 28, 2013 at 3:55 pm #116Jean ValleeParticipant
How do I set this property? appw.form.currentpage.wxformpage.focuscontrol.name It’s read only…. I’m trying to shift focus to another field before calling a getuserinput called from a dataform1button with an ongotfocus event. Per a previous thread, I know I have to change the focus prior to calling getuserinput but nothing I’ve tried changes the focuscontrol.name property so getuserinput is being called over and over. Jean Vallee
April 29, 2013 at 5:43 pm #2228MichaelKeymasterOn 28/04/2013 16:55, JV wrote:
> How do I set this property?
> appw.form.currentpage.wxformpage.focuscontrol.name
>
> It's read only….
>
> I'm trying to shift focus to another field before calling a getuserinput
> called from a dataform1button with an ongotfocus event.
>
> Per a previous thread, I know I have to change the focus prior to
> calling getuserinput but nothing I've tried changes the
> focuscontrol.name property so getuserinput is being called over and over.To set focus to another control, use control.setfocus().
Ciao, Neil
April 30, 2013 at 3:23 am #2232Jean ValleeParticipantOn 4/29/2013 1:43 PM, Neil Robinson wrote:
> On 28/04/2013 16:55, JV wrote:
>> How do I set this property?
>> appw.form.currentpage.wxformpage.focuscontrol.name
>>
>> It's read only….
>>
>> I'm trying to shift focus to another field before calling a getuserinput
>> called from a dataform1button with an ongotfocus event.
>>
>> Per a previous thread, I know I have to change the focus prior to
>> calling getuserinput but nothing I've tried changes the
>> focuscontrol.name property so getuserinput is being called over and over.
>
> To set focus to another control, use control.setfocus().
>
> Ciao, NeilI did that but it did not change the focuscontrol.name.
so when I exit a dialog it's repeating the ongotfocus event.// get value at beginning
string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
// x = selcntrbtn – this control has the ongotfocus attached to it.
// setfocus somewhere else
if app.prmttype == "1"
me!MechName.setfocus()
else
me!ProjDesc.setfocus()
end if
// immediately test value again
string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
// x is still selcntrbtnJean
>April 30, 2013 at 1:30 pm #2236MichaelKeymasterOn 30/04/2013 04:23, JV wrote:
> On 4/29/2013 1:43 PM, Neil Robinson wrote:
>> On 28/04/2013 16:55, JV wrote:
>>> How do I set this property?
>>> appw.form.currentpage.wxformpage.focuscontrol.name
>>>
>>> It's read only….
>>>
>>> I'm trying to shift focus to another field before calling a getuserinput
>>> called from a dataform1button with an ongotfocus event.
>>>
>>> Per a previous thread, I know I have to change the focus prior to
>>> calling getuserinput but nothing I've tried changes the
>>> focuscontrol.name property so getuserinput is being called over and over.
>>
>> To set focus to another control, use control.setfocus().
>>
>> Ciao, Neil
>
> I did that but it did not change the focuscontrol.name.
> so when I exit a dialog it's repeating the ongotfocus event.
>
> // get value at beginning
> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
> // x = selcntrbtn – this control has the ongotfocus attached to it.
> // setfocus somewhere else
> if app.prmttype == "1"
> me!MechName.setfocus()
> else
> me!ProjDesc.setfocus()
> end if
> // immediately test value again
> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
> // x is still selcntrbtn
>
> Jean
>>
>If you are popping up a dialog in an onlostfocus event, are you setting the focus with the dialog still up? If so, wxWidgets will
mess you over. It stores the ID of the control that last had focus when the window loses focus, and restores it when the window
receives focus again. I have not been able to find a clean way to prevent this yet (but not for lack of trying). To solve this, in
your onlostfocus event where you call the dialog, disable the event when going into the function, set focus to the correct control
after you return from the dialog call, and just before exiting restore the function to the onlostfocus event for the control.I know it is messy, but it is unfortunately caused by the screwy behavior of wxWidgets.
Ciao, Neil
April 30, 2013 at 4:48 pm #2239Jean ValleeParticipantOn 4/30/2013 9:30 AM, Neil Robinson wrote:
> On 30/04/2013 04:23, JV wrote:
>> On 4/29/2013 1:43 PM, Neil Robinson wrote:
>>> On 28/04/2013 16:55, JV wrote:
>>>> How do I set this property?
>>>> appw.form.currentpage.wxformpage.focuscontrol.name
>>>>
>>>> It's read only….
>>>>
>>>> I'm trying to shift focus to another field before calling a getuserinput
>>>> called from a dataform1button with an ongotfocus event.
>>>>
>>>> Per a previous thread, I know I have to change the focus prior to
>>>> calling getuserinput but nothing I've tried changes the
>>>> focuscontrol.name property so getuserinput is being called over and over.
>>>
>>> To set focus to another control, use control.setfocus().
>>>
>>> Ciao, Neil
>>
>> I did that but it did not change the focuscontrol.name.
>> so when I exit a dialog it's repeating the ongotfocus event.
>>
>> // get value at beginning
>> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
>> // x = selcntrbtn – this control has the ongotfocus attached to it.
>> // setfocus somewhere else
>> if app.prmttype == "1"
>> me!MechName.setfocus()
>> else
>> me!ProjDesc.setfocus()
>> end if
>> // immediately test value again
>> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
>> // x is still selcntrbtn
>>
>> Jean
>>>
>>
>
> If you are popping up a dialog in an onlostfocus event, are you setting the focus with the dialog still up? If so, wxWidgets will
> mess you over. It stores the ID of the control that last had focus when the window loses focus, and restores it when the window
> receives focus again. I have not been able to find a clean way to prevent this yet (but not for lack of trying). To solve this, in
> your onlostfocus event where you call the dialog, disable the event when going into the function, set focus to the correct control
> after you return from the dialog call, and just before exiting restore the function to the onlostfocus event for the control.
>
> I know it is messy, but it is unfortunately caused by the screwy behavior of wxWidgets.
>
> Ciao, Neil
I am not calling a dialog per se but I think getuserinput is a glorified
one…
But I am not setting focus with the dialog still up but BEFORE the
dialog is even called. Code above is followed by a getuserinput
statement so you can see where I'm setting focus to another field before
even getting to any dialog yet it still did not change.Can you tell me why the code snippet above did not change the
focuscontrol property?Jean
May 2, 2013 at 5:15 pm #2240MichaelKeymasterOn 30/04/2013 17:48, JV wrote:
> On 4/30/2013 9:30 AM, Neil Robinson wrote:
>> On 30/04/2013 04:23, JV wrote:
>>> On 4/29/2013 1:43 PM, Neil Robinson wrote:
>>>> On 28/04/2013 16:55, JV wrote:
>>>>> How do I set this property?
>>>>> appw.form.currentpage.wxformpage.focuscontrol.name
>>>>>
>>>>> It's read only….
>>>>>
>>>>> I'm trying to shift focus to another field before calling a getuserinput
>>>>> called from a dataform1button with an ongotfocus event.
>>>>>
>>>>> Per a previous thread, I know I have to change the focus prior to
>>>>> calling getuserinput but nothing I've tried changes the
>>>>> focuscontrol.name property so getuserinput is being called over and over.
>>>>
>>>> To set focus to another control, use control.setfocus().
>>>>
>>>> Ciao, Neil
>>>
>>> I did that but it did not change the focuscontrol.name.
>>> so when I exit a dialog it's repeating the ongotfocus event.
>>>
>>> // get value at beginning
>>> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
>>> // x = selcntrbtn – this control has the ongotfocus attached to it.
>>> // setfocus somewhere else
>>> if app.prmttype == "1"
>>> me!MechName.setfocus()
>>> else
>>> me!ProjDesc.setfocus()
>>> end if
>>> // immediately test value again
>>> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
>>> // x is still selcntrbtn
>>>
>>> Jean
>>>>
>>>
>>
>> If you are popping up a dialog in an onlostfocus event, are you setting the focus with the dialog still up? If so, wxWidgets will
>> mess you over. It stores the ID of the control that last had focus when the window loses focus, and restores it when the window
>> receives focus again. I have not been able to find a clean way to prevent this yet (but not for lack of trying). To solve this, in
>> your onlostfocus event where you call the dialog, disable the event when going into the function, set focus to the correct control
>> after you return from the dialog call, and just before exiting restore the function to the onlostfocus event for the control.
>>
>> I know it is messy, but it is unfortunately caused by the screwy behavior of wxWidgets.
>>
>> Ciao, Neil
> I am not calling a dialog per se but I think getuserinput is a glorified
> one…
> But I am not setting focus with the dialog still up but BEFORE the
> dialog is even called. Code above is followed by a getuserinput
> statement so you can see where I'm setting focus to another field before
> even getting to any dialog yet it still did not change.
>
> Can you tell me why the code snippet above did not change the
> focuscontrol property?
>
> Jean
>Until you return to the wxprocess() (by leaving the event handler) I don't think you will see the result of your setfocus() call.
Also, you should setfocus() after you call getuserinput() which is implemented using a dialog. It doesn't actually matter that it
is a dialog, what matters is that whatever you did resulted in a loss of focus to the current form. It could be an appactivate().Ciao, Neil
May 2, 2013 at 6:46 pm #2247Jean ValleeParticipantOn 5/2/2013 1:15 PM, Neil Robinson wrote:
> On 30/04/2013 17:48, JV wrote:
>> On 4/30/2013 9:30 AM, Neil Robinson wrote:
>>> On 30/04/2013 04:23, JV wrote:
>>>> On 4/29/2013 1:43 PM, Neil Robinson wrote:
>>>>> On 28/04/2013 16:55, JV wrote:
>>>>>> How do I set this property?
>>>>>> appw.form.currentpage.wxformpage.focuscontrol.name
>>>>>>
>>>>>> It's read only….
>>>>>>
>>>>>> I'm trying to shift focus to another field before calling a getuserinput
>>>>>> called from a dataform1button with an ongotfocus event.
>>>>>>
>>>>>> Per a previous thread, I know I have to change the focus prior to
>>>>>> calling getuserinput but nothing I've tried changes the
>>>>>> focuscontrol.name property so getuserinput is being called over and over.
>>>>>
>>>>> To set focus to another control, use control.setfocus().
>>>>>
>>>>> Ciao, Neil
>>>>
>>>> I did that but it did not change the focuscontrol.name.
>>>> so when I exit a dialog it's repeating the ongotfocus event.
>>>>
>>>> // get value at beginning
>>>> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
>>>> // x = selcntrbtn – this control has the ongotfocus attached to it.
>>>> // setfocus somewhere else
>>>> if app.prmttype == "1"
>>>> me!MechName.setfocus()
>>>> else
>>>> me!ProjDesc.setfocus()
>>>> end if
>>>> // immediately test value again
>>>> string x ; x = appw.form.currentpage.wxformpage.focuscontrol.name
>>>> // x is still selcntrbtn
>>>>
>>>> Jean
>>>>>
>>>>
>>>
>>> If you are popping up a dialog in an onlostfocus event, are you setting the focus with the dialog still up? If so, wxWidgets will
>>> mess you over. It stores the ID of the control that last had focus when the window loses focus, and restores it when the window
>>> receives focus again. I have not been able to find a clean way to prevent this yet (but not for lack of trying). To solve this, in
>>> your onlostfocus event where you call the dialog, disable the event when going into the function, set focus to the correct control
>>> after you return from the dialog call, and just before exiting restore the function to the onlostfocus event for the control.
>>>
>>> I know it is messy, but it is unfortunately caused by the screwy behavior of wxWidgets.
>>>
>>> Ciao, Neil
>> I am not calling a dialog per se but I think getuserinput is a glorified
>> one…
>> But I am not setting focus with the dialog still up but BEFORE the
>> dialog is even called. Code above is followed by a getuserinput
>> statement so you can see where I'm setting focus to another field before
>> even getting to any dialog yet it still did not change.
>>
>> Can you tell me why the code snippet above did not change the
>> focuscontrol property?
>>
>> Jean
>>
>
> Until you return to the wxprocess() (by leaving the event handler) I don't think you will see the result of your setfocus() call.
> Also, you should setfocus() after you call getuserinput() which is implemented using a dialog. It doesn't actually matter that it
> is a dialog, what matters is that whatever you did resulted in a loss of focus to the current form. It could be an appactivate().
>
> Ciao, NeilI ended up using your "messy" suggestion and it was actually not messy
all, just not elegant. At this point, if it gets the job done that's all
I need.Thanks!
Jean - AuthorPosts
- You must be logged in to reply to this topic.