#PB_Event_GadgetFocus

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

#PB_Event_GadgetFocus

Post by BarryG »

Per what TI-994A said here -> viewtopic.php?p=565895#p565895

We need a way to detect when any of our gadgets get the focus (as shown when the dotted focus rectangle is on them), without resorting to silly hacks like I did by comparing old/new GetActiveGadget(), or like TI-994A did by using AddKeyboardShortcut().

Thanks!
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: #PB_Event_GadgetFocus

Post by STARGÅTE »

This event is implemented in EventType(): #PB_EventType_Focus

Code: Select all

OpenWindow(1, 200, 200, 300, 100, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

StringGadget(1, 10, 10, 280, 25, "A")
StringGadget(2, 10, 40, 280, 25, "B")
StringGadget(3, 10, 70, 280, 25, "C")

SetActiveGadget(1)

Repeat
	
	Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			End
		Case #PB_Event_Gadget
			Select EventType()
				Case #PB_EventType_Focus
					Debug "Focus on gadget #"+EventGadget()
			EndSelect
	EndSelect
	
ForEver
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Re: #PB_Event_GadgetFocus

Post by BarryG »

STARGÅTE, I know that, but #PB_EventType_Focus doesn't support all gadgets that use the keyboard (such as ComboBoxGadgets), which is what this request is about.

I did say this request is to support "any gadget that gets the dotted focus rectangle on them", which means it's a keyboard-supported gadget. <Wink>.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: #PB_Event_GadgetFocus

Post by STARGÅTE »

@BarryG, you are right. I did not noticed, that the list of supported gadget is relatively small and gadgets like Button or CheckBox are not included.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Post Reply