Hi Coders :-)
How do I find which gadget, a button, was pressed?
There is a yawning cavity where this knowledge should be :-/
Here's my code:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Global xres:Int = GadgetWidth(Desktop:TGadget())
Global yres:Int = GadgetHeight(Desktop:TGadget())
Global px:Int = (xres/2) - 315
Global py:Int = (yres/2) - 55
Global window:TGadget=CreateWindow("Compare Files", px, py, 630, 109, Null, 3|WINDOW_ACCEPTFILES)
Global file1:TGadget = CreateTextField:TGadget(0, 2, 620, 22, window)
Global file2:TGadget = CreateTextField:TGadget(0, 28, 620, 22, window)
Global button:TGadget = CreateButton:TGadget("OK", 0, 55, 620, 22, window, BUTTON_OK)
Repeat
WaitEvent()
If EventID()=EVENT_WINDOWACCEPT
If TextFieldText(file1)>""
SetGadgetText(file2, EventText())
Else
SetGadgetText(file1, EventText())
EndIf
EndIf
If EventID()=EVENT_WINDOWCLOSE End
SetGadgetText(file1, ButtonState(button))
Forever
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you run this yourself, you'll see that no matter how much I click the button, the ButtonState does not vary from zero.
I obviously need to uniquely identify the button and I do not know how.
Can anyone help, please?
Julian ((*)(*))
How do I find which gadget, a button, was pressed?
There is a yawning cavity where this knowledge should be :-/
Here's my code:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Global xres:Int = GadgetWidth(Desktop:TGadget())
Global yres:Int = GadgetHeight(Desktop:TGadget())
Global px:Int = (xres/2) - 315
Global py:Int = (yres/2) - 55
Global window:TGadget=CreateWindow("Compare Files", px, py, 630, 109, Null, 3|WINDOW_ACCEPTFILES)
Global file1:TGadget = CreateTextField:TGadget(0, 2, 620, 22, window)
Global file2:TGadget = CreateTextField:TGadget(0, 28, 620, 22, window)
Global button:TGadget = CreateButton:TGadget("OK", 0, 55, 620, 22, window, BUTTON_OK)
Repeat
WaitEvent()
If EventID()=EVENT_WINDOWACCEPT
If TextFieldText(file1)>""
SetGadgetText(file2, EventText())
Else
SetGadgetText(file1, EventText())
EndIf
EndIf
If EventID()=EVENT_WINDOWCLOSE End
SetGadgetText(file1, ButtonState(button))
Forever
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you run this yourself, you'll see that no matter how much I click the button, the ButtonState does not vary from zero.
I obviously need to uniquely identify the button and I do not know how.
Can anyone help, please?
Julian ((*)(*))