how does a gadget recognize that it has the focus?

BlitzMax Forums/BlitzMax Programming/how does a gadget recognize that it has the focus?

Rozek(Posted 2010) [#1]
Hello!

I am currently developing a few TProxyGadgets for my application. Now I have the problem that I would like to know when my gadgets gain/loose the keyboard focus in order to update their visual appearance

I could neither find any events informing about this state change nor a pair of functions (such as "ActivateGadget" - which exists - and "InactivateGadget" - which does not exist)

Is there any way to keep track of the focus?

Of course, I could regularly check "ActiveGadget" and update my gadget's state accordingly - but this does not sound like an efficient (and elegant) approach.

Is there any alternative?

Thanks in advance for any hint!


jsp(Posted 2010) [#2]
Depends on the gadgets on top of the proxy gadget.
Textfields and Textarea produce a gadgetlostfocus event.
And for Panels and Canvas you could use the mouse enter and mouse leave event.
If you need more for some reason, you could also enable SetGadgetSensitivity( YourGadget:TGadget,SENSITIZE_MOUSE|SENSITIZE_KEYS )


Rozek(Posted 2010) [#3]
Hello!

Thanks for your response!

Is the "GadgetLostFocus" event documented? I could not find any mention of it in the docs

And, unfortunately, mouse enter and mouse leave events must *not* be used for focus management (as you may also operate GUI-based applications with the keyboard only (the better ones, at least))

Currently, I see no other way as to observe the currently active gadget and inform the previous one about focus loss.


jsp(Posted 2010) [#4]
Find below an example of the EVENT_GADGETLOSTFOCUS.

Currently, I see no other way as to observe the currently active gadget and inform the previous one about focus loss.

What do you change in case of focus / no focus.




Rozek(Posted 2010) [#5]
Hello!

Thanks for the example code!

I want to provide some visual feedback in case while a gadget owns the keyboard focus - that's what I need these events for.