Skip to content

focuscontrol

Forums Forums SIMPOL Programming focuscontrol

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #116
    Jean Vallee
    Participant

    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

    #2228
    Michael
    Keymaster

    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

    #2232
    Jean Vallee
    Participant

    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
    >

    #2236
    Michael
    Keymaster

    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

    #2239
    Jean Vallee
    Participant

    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

    #2240
    Michael
    Keymaster

    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, Neil

    #2247
    Jean Vallee
    Participant

    On 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, Neil

    I 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

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.