It could be the way you are calling and looking at events... try this method from the included VD
Code: Select all
Enumeration
#Button_0
#String_0
EndEnumeration
Global Window_0
Structure VisualDesignerGadgets
Gadget.l
EventFunction.l
EndStructure
Global NewList EventProcedures.VisualDesignerGadgets()
Procedure String_0_Event(Window, Event, Gadget, Type)
Debug "#String_0"
EndProcedure
Procedure Button_0_Event(Window, Event, Gadget, Type)
Debug "#Button_0"
SetGadgetText(#String_0, "")
EndProcedure
Procedure RegisterGadgetEvent(Gadget, *Function)
If IsGadget(Gadget)
AddElement(EventProcedures())
EventProcedures()\Gadget = Gadget
EventProcedures()\EventFunction = *Function
EndIf
EndProcedure
Procedure CallEventFunction(Window, Event, Gadget, Type)
ForEach EventProcedures()
If EventProcedures()\Gadget = Gadget
CallFunctionFast(EventProcedures()\EventFunction, Window, Event, Gadget, Type)
LastElement(EventProcedures())
EndIf
Next
EndProcedure
Procedure Open_Window_0()
Window_0 = OpenWindow(#PB_Any, 5, 5, 400, 157, "Window 0", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
If Window_0
If CreateGadgetList(WindowID(Window_0))
ButtonGadget(#Button_0, 10, 80, 120, 50, "BUTTON")
RegisterGadgetEvent(#Button_0, @Button_0_Event())
StringGadget(#String_0, 10, 20, 370, 30, "")
RegisterGadgetEvent(#String_0, @String_0_Event())
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
Gadget = EventGadget()
Type = EventType()
Window = EventWindow()
Select Event
Case #PB_Event_Gadget
CallEventFunction(Window, Event, Gadget, Type)
EndSelect
Until Event = #PB_Event_CloseWindow
End
or this method from PUREform
Code: Select all
;{- Enumerations / DataSections
;{ Windows
Enumeration
#Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
#String_0
#Button_1
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 450, 200, 400, 152, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
StringGadget(#String_0, 15, 10, 360, 30, "")
ButtonGadget(#Button_1, 20, 55, 165, 50, "BUTTON")
EndIf
EndProcedure
OpenWindow_Window_0()
;{- Event loop
Repeat
Event = WaitWindowEvent()
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #String_0
; essentially do NOTHING (in fact this can be deleted as an instance)
ElseIf EventGadget = #Button_1
SetGadgetText(#String_0, "")
EndIf
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
ForEver
;
;}
perhaps I misunderstood... with mine code you can click anywhere and modify the text...