Get variable from GUI
Posted: Tue Oct 29, 2024 2:43 pm
There is a test program
It gets the value of variable A.s by pressing the button. But I need GetGadgetText(#STRING_INPUT) to work constantly, in a cycle (for example, with an interval of 500 ms) and variable A.s =GetGadgetText(#STRING_INPUT) to be updated automatically, without waiting for the button to be pressed. How can I do this?
Code: Select all
Enumeration
#WIN_MAIN
#BUTTON_INTERACT
#BUTTON_CLOSE
#STRING_INPUT
EndEnumeration
Global Quit.b = #False
#FLAGS = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(#WIN_MAIN, 0, 0, 300, 200, "Test", #FLAGS)
ButtonGadget(#BUTTON_INTERACT, 20, 150, 100, 30, "Btn 1")
ButtonGadget(#BUTTON_CLOSE, 170, 150, 100, 30, "Btn 2")
StringGadget(#STRING_INPUT, 10, 30, 280, 30, "")
SetActiveGadget(#STRING_INPUT)
Repeat
Event.l = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #BUTTON_INTERACT
A.s =GetGadgetText(#STRING_INPUT)
Case #BUTTON_CLOSE
Quit = #True
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow Or Quit = #True
EndIf
End