I need to know, which one of several gadgets is activated.
Setting the focus to a gadget is easy with activategadget(#),
but I didn't find a function, to GET the number of the active gadget (which could have changed since the last activategadget)
How to find out, which of the gadgets is activated?
Simple solution
I found out a simple solution for myself *g*
to test, if gadget(x) is activated, I now use the following lines
to test, if gadget(x) is activated, I now use the following lines
thefocusishere=getfocus_()
if gadgetid(gadget(x)) = thefocusishere
; gadget(x) has the focus!
endif
Does this method work with ComboBoxGadget?
I make a ComboBox thus:
And set up a hot key:
And then try to detect if the user has pressed RETURN on it in the #PB_EventMenu handler:
No beeps!
The two debug values look 'real'... but are different
I make a ComboBox thus:
Code: Select all
ComboBoxGadget(3,Gx+5,Gy+15,100,200,#PB_ComboBox_Editable )
Code: Select all
AddKeyboardShortcut(1, #PB_Shortcut_Return ,504)
Code: Select all
Case 504 ; Hot key 'RETURN'
Debug GetFocus_()
Debug GadgetID(3)
If GetFocus_() = GadgetID(3)
MyBeep(1000,100)
EndIf
The two debug values look 'real'... but are different

OK, found it by searching this site... it seems the ComboBox is a special case.
As my mother used to say...
"None so blind as those who do not look in the right place!"
Code: Select all
Case 504 ; Hot key 'RETURN'
If GetFocus_() = GetWindow_(GadgetID(3), #GW_CHILD)
MyBeep(1000,100)
EndIf
"None so blind as those who do not look in the right place!"