Editor Gadgets are EventGadget() Kings
Posted: Tue May 28, 2013 1:26 am
This is something I didn't know until now.
I have a Window with gadgets that mainly consist of StringGadgets and EditorGadgets. In the event loop, I want to detect which gadget the User has clicked on. However, until another gadget is clicked on, if an EditorGadget is there, it is the EventGadget() -even if, prior to starting the loop, another gadget is set as Active.
So, is there a way to prevent the Editor Gadget(s) being the EventGadget() until the User clicks on them - i.e. same behaviour as the string gadgets in the sample code?
I have a Window with gadgets that mainly consist of StringGadgets and EditorGadgets. In the event loop, I want to detect which gadget the User has clicked on. However, until another gadget is clicked on, if an EditorGadget is there, it is the EventGadget() -even if, prior to starting the loop, another gadget is set as Active.
Code: Select all
Enumeration
#Win ;0
#BtnExit ;1
#Str01 ;2
#Str02 ;3
#Str03 ;4
#Editor01 ;5
EndEnumeration
Procedure Win()
;--------------
Protected iEvent.i, iGadget.i, iStop.i = #False
If OpenWindow(#Win, 0, 0, 300, 240, "Editor Gadget Event", #PB_Window_TitleBar | #PB_Window_ScreenCentered)
ButtonGadget(#BtnExit, 10, 200, 280, 30, "EXIT")
StringGadget(#Str01, 10, 10, 280, 20, "#Str01")
StringGadget(#Str02, 10, 40, 280, 20, "#Str02")
StringGadget(#Str03, 10, 70, 280, 20, "#Str03")
EditorGadget(#Editor01, 10, 100, 280, 90)
SetGadgetText(#Editor01, "Editor01")
EndIf
SetActiveGadget(#BtnExit)
Repeat
iEvent = WaitWindowEvent()
Select iEvent
Case #PB_Event_Gadget
iGadget = EventGadget()
Debug iGadget
If(iGadget = #BtnExit)
iStop = #True
Else
SetGadgetColor(iGadget,#PB_Gadget_BackColor,RGB(0,128,255))
EndIf
EndSelect
Until(iStop = #True)
EndProcedure
Win()
End