How to know the current control?

User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: How to know the current control?

Post by nageswaragunupudi »

Code: Select all

If oDlg:aControls[i]:lFocused
            //-- Your function
            exit
        end
"//--Your function" never gets executed in this case, because when the VK button is clicked no Get object has focus.

We want to know the Get that was in focus before pressing the VK button, which has already lost focus.
Regards

G. N. Rao.
Hyderabad, India
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: How to know the current control?

Post by James Bott »

Perhaps you could use the GETs bLostFocus codeblock to call a set/get function that stores the GET that last had focus. This would work for any control, not just GETs.

James
----------------------------

Code: Select all

oGet:bLostFocus:={| | LastFocus( self ) }

Then you could simply do:

setFocus( LastFocus() )


// Set/Get function to store last focused control
static function LastFocus( oControl )
   local oReply
   static oOldControl
   oReply:= oOldControl
   if oControl != nil
      oOldControl:= oControl
   endif
return oReply
Post Reply