Is there something that will return a 1 if a StringGadget or ButtonGadget has the focus or cursor blinking in it and a 0 if it does not have the focus? What I mean by focus is: If I place the cursor in one StringGadget then press TAB the 'Focus' (In this case, the cursor) moves to the next StringGadget or Button Gadget (in the case of a ButtonGadget there is a dotted rectangle around the button text) to the right, or next line down and left most, if right most gadget has been met.
I require this to work for StringGadgets and ButtonGadgets.
I will check to see which row of gadgets has the focus and that will determine which ButtonGadget is 'clicked' or activated when I press the Enter Key.
Focus of Cursor
Re: Focus of Cursor
Do you have code for the window and gadgets to experiment with?
Last edited by Mijikai on Sun Nov 29, 2020 6:56 pm, edited 3 times in total.
Re: Focus of Cursor
Yes, something like this:
I have extended that to 2 rows of StringGadgets and ButtonGadgets
Code: Select all
EnableExplicit
Enumeration
#InputText
#InputString
#ResultText
#ResultString
#ConvertButton
EndEnumeration
Define Event.i, Exit.i, Input$
OpenWindow(0, 0, 0, 220, 100, "Inch To cm", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(#InputText, 10, 10, 60, 20, "Input")
TextGadget(#ResultText, 150, 10, 60, 20, "Result")
StringGadget(#InputString, 10, 40, 60, 20, "0")
ButtonGadget(#ConvertButton, 80, 40, 60, 20, "Convert")
StringGadget(#ResultString, 150, 40, 60, 20, "0")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #InputString
Input$ = GetGadgetText(#InputString)
If Input$ = ""
DisableGadget(#ConvertButton, #True)
Else
DisableGadget(#ConvertButton, #False)
EndIf
Case #ConvertButton
SetGadgetText(#ResultString, StrF(ValD(GetGadgetText(#InputString)) * 2.54, 3))
EndSelect
Case #PB_Event_CloseWindow
Exit = #True
EndSelect
Until Exit
Re: Focus of Cursor
Mby this helps...
Or do you need a GadgetHover() function?
Code: Select all
Procedure.i GadgetActive(Gadget.i)
ProcedureReturn Bool(Gadget = GetActiveGadget())
EndProcedure
Re: Focus of Cursor
Hi
Code: Select all
EnableExplicit
Enumeration
#InputText
#InputString
#ResultText
#ResultString
#ConvertButton
#TextGadget
EndEnumeration
Define Event.i, Exit.i, Input$
OpenWindow(0, 0, 0, 220, 100, "Inch To cm", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(#InputText, 10, 10, 60, 20, "Input")
TextGadget(#ResultText, 150, 10, 60, 20, "Result")
StringGadget(#InputString, 10, 40, 60, 20, "0")
ButtonGadget(#ConvertButton, 80, 40, 60, 20, "Convert")
StringGadget(#ResultString, 150, 40, 60, 20, "0")
TextGadget(#TextGadget,10,70,200,20,"Gadget : "+Str(GetActiveGadget())+" has the focus")
AddWindowTimer(0,10,100)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Timer
SetGadgetText(#TextGadget,"Gadget : "+Str(GetActiveGadget())+" has the focus")
Case #PB_Event_Gadget
Select EventGadget()
Case #InputString
Input$ = GetGadgetText(#InputString)
If Input$ = ""
DisableGadget(#ConvertButton, #True)
Else
DisableGadget(#ConvertButton, #False)
EndIf
Case #ConvertButton
SetGadgetText(#ResultString, StrF(ValD(GetGadgetText(#InputString)) * 2.54, 3))
EndSelect
Case #PB_Event_CloseWindow
Exit = #True
EndSelect
Until Exit
Egypt my love
Re: Focus of Cursor
Brilliant Guys, thanks.