Page 1 of 1
BindEvent order
Posted: Thu Jul 16, 2015 1:38 pm
by mestnyi
Code: Select all
Procedure FormEvent( ) ;Ok
Select EventType( )
Case #PB_EventType_LeftButtonDown
Debug 1
EndSelect
EndProcedure
Procedure FormEvent_1( ) ;Ok
Select EventType( )
Case #PB_EventType_LeftButtonDown
Debug 3
EndSelect
EndProcedure
;----------examle1-----------------
BindEvent(#PB_Event_Window, @FormEvent(), Window)
BindEvent(#PB_Event_Window, @FormEvent_1(), Window)
;event
;first Debug 3
;second Debug 1
If I added bindevent and followed by another
purebasik first treated (second bindevent), and then (the first bindevent).
Can I make is processed in a manner that was adding bindevents?
Re: BindEvent order
Posted: Thu Nov 19, 2015 8:28 am
by mestnyi
I expect that will happen the first event 1
2 event occurs.
Is it possible to change the order of the call?
Code: Select all
Procedure Event_1( )
Debug "Event_1_LeftClick"
EndProcedure
Procedure Event_2( )
Debug "Event_2_LeftClick"
EndProcedure
OpenWindow(1, 200, 100, 150, 100, "Event_1")
BindEvent(#PB_Event_LeftClick, @Event_1(), 1)
BindEvent(#PB_Event_LeftClick, @Event_2(), 1)
While WaitWindowEvent() ! #PB_Event_CloseWindow :Wend
Re: BindEvent order
Posted: Fri Mar 11, 2016 7:45 am
by mestnyi
Code: Select all
DeclareModule Canvas
Declare Create(Gadget, Text.s = "CanvasGadget")
EndDeclareModule
Module Canvas
Procedure CanvasHandler()
Select EventType()
Case #PB_EventType_LeftClick
Debug "Click event on gadget and set value - " + SetGadgetData(EventGadget(),@"set value = #PB_EventType_LeftClick")
EndSelect
EndProcedure
Procedure Create(Gadget, Text.s = "CanvasGadget")
CanvasGadget(Gadget, 10, 10, 180, 30, #PB_Canvas_Border)
If StartDrawing(CanvasOutput( Gadget ))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0,0,OutputWidth(),OutputHeight())
DrawText((GadgetWidth(Gadget)-TextWidth(Text))/2, (GadgetHeight(Gadget)-TextHeight(Text))/2, Text,0)
StopDrawing()
EndIf
BindGadgetEvent(0, @CanvasHandler())
EndProcedure
EndModule
OpenWindow(0, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu)
Canvas::Create(0)
Procedure CanvasHandler()
Select EventType()
Case #PB_EventType_LeftClick
*Value = GetGadgetData(EventGadget())
If *Value
Debug "click event on gadget and get value - " + PeekS(*Value)
Else
Debug "We do not get value because it is not implemented properly bindevent "
Debug "Event module must occur first , as in the module was bindevent was called first"
EndIf
EndSelect
EndProcedure
BindGadgetEvent(0, @CanvasHandler())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Is not that right?
Re: BindEvent order
Posted: Fri Mar 11, 2016 8:23 am
by mhs
I did not know that it works to bind twice at the same gadget and event...
Looks like it was designed as a stack.
Would that be an alternative?
Code: Select all
DeclareModule Canvas
Declare Create(Gadget, Text.s = "CanvasGadget")
Declare SetEvent(*EventFunction)
EndDeclareModule
Module Canvas
Global *Event
Procedure CanvasHandler()
Select EventType()
Case #PB_EventType_LeftClick
Debug "Click event on gadget and set value - " + SetGadgetData(EventGadget(),@"set value = #PB_EventType_LeftClick")
EndSelect
If *Event
CallFunctionFast(*Event)
EndIf
EndProcedure
Procedure Create(Gadget, Text.s = "CanvasGadget")
CanvasGadget(Gadget, 10, 10, 180, 30, #PB_Canvas_Border)
If StartDrawing(CanvasOutput( Gadget ))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0,0,OutputWidth(),OutputHeight())
DrawText((GadgetWidth(Gadget)-TextWidth(Text))/2, (GadgetHeight(Gadget)-TextHeight(Text))/2, Text,0)
StopDrawing()
EndIf
BindGadgetEvent(0, @CanvasHandler())
EndProcedure
Procedure SetEvent(*EventFunction)
*Event = *EventFunction
EndProcedure
EndModule
OpenWindow(0, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu)
Canvas::Create(0)
Procedure CanvasHandler()
Select EventType()
Case #PB_EventType_LeftClick
*Value = GetGadgetData(EventGadget())
If *Value
Debug "click event on gadget and get value - " + PeekS(*Value)
Else
Debug "We do not get value because it is not implemented properly bindevent "
Debug "Event module must occur first , as in the module was bindevent was called first"
EndIf
EndSelect
EndProcedure
;BindGadgetEvent(0, @CanvasHandler())
Canvas::SetEvent(@CanvasHandler())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Re: BindEvent order
Posted: Fri Mar 11, 2016 8:57 am
by mestnyi
Would that be an alternative?
I would like to out of the box so it was .
That is the behavior I expected, thank you.
