Page 1 of 1
What is PostEvent() window # without optional paramater
Posted: Wed Nov 18, 2015 8:16 am
by BasicallyPure
If PostEvent(Event [, Window, Object [, Type [, Data]]]) is used without the optional Window parameter
what is the Window number returned by EventWindow()?
The help does not specify what this will be but I always assumed it was the current window's number.
It appears that EventWindow() always returns 0 if PostEvent() is used without the optional window parameter.
Code: Select all
OpenWindow(10,0,0,250,200, "PostEvent & EventWindow", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_RightClick
PostEvent(#PB_Event_LeftClick) ;<-- this way generates EventWindow() = 0
;PostEvent(#PB_Event_LeftClick,10,#PB_Ignore) ;<-- this way works
Case #PB_Event_LeftClick
Ev_Window = EventWindow()
Debug "Event_LeftClick : EventWindow = " + Ev_Window
If Ev_Window <> 10 And Ev_Window <> -1
Debug "why? EventWindow() must be 10 or -1 "
EndIf
EndSelect
ForEver
Re: What is PostEvent() window # without optional paramater
Posted: Wed Nov 18, 2015 9:29 am
by Fred
No, it won't be the current window, as there is no current window (or you mean active window ?). If you don't specify the parameter, it will be 0. May be it would be better to use #PB_All as default value. I will move to feature and request for further inspection.
Re: What is PostEvent() window # without optional paramater
Posted: Wed Nov 18, 2015 5:09 pm
by BasicallyPure
Thank you for your response Fred.
Fred wrote:No, it won't be the current window, as there is no current window (or you mean active window ?).
Yes I mean active window.
Re: What is PostEvent() window # without optional paramater
Posted: Wed Nov 18, 2015 6:51 pm
by GPI
Maybe a new konstant #pb_windowid_broadcast would be a solution.
Re: What is PostEvent() window # without optional paramater
Posted: Wed Nov 18, 2015 9:07 pm
by mestnyi
May be it would be better to use #PB_All as default value
That would be correct.
Re: What is PostEvent() window # without optional paramater
Posted: Wed Nov 18, 2015 9:19 pm
by kenmo
Fred wrote:May be it would be better to use #PB_All as default value. I will move to feature and request for further inspection.
Maybe another named constant, with the same value of -1.
#PB_All might be confusing: user might think that #PB_All posts a copy of the event to ALL opened windows.
Re: What is PostEvent() window # without optional paramater
Posted: Thu Nov 19, 2015 6:18 am
by Danilo
kenmo wrote:Maybe another named constant, with the same value of -1.
#PB_All might be confusing: user might think that #PB_All posts a copy of the event to ALL opened windows.
-1 is already used internally for non-valid events, so I think it's good to use -1 there as well. It means no Window number is specified,
and EventWindow() number is not valid / can't be used.
#PB_All would indeed indicate that it is for all Windows. If that would be the case, all BindEvent() callbacks for all Windows
must be called for that specific message.
IMO if you don't specify a Window, it is not for a specific Window, so just -1 should be fine. Or #PB_Ignore / #PB_Unknown / #PB_Unspecified
Re: What is PostEvent() window # without optional paramater
Posted: Thu Nov 19, 2015 8:45 am
by mestnyi
-1 is already used internally for non-valid events, so I think it's good to use -1 there as well
I agree
all BindEvent() callbacks for all Windows
must be called for that specific message.
That's not quite understand, but if you say you want to change.
That is not to call for all windows and just for a specific window.
I say do not touch because it works very well.
Code: Select all
Procedure Event( )
Debug "Event_LeftClick "+EventWindow()
EndProcedure
OpenWindow(1, 200, 100, 150, 100, "Window_1")
OpenWindow(2, 400, 100, 150, 100, "Window_2")
BindEvent(#PB_Event_LeftClick, @Event())
While WaitWindowEvent() ! #PB_Event_CloseWindow :Wend
Re: What is PostEvent() window # without optional paramater
Posted: Sun Oct 08, 2017 8:59 am
by mestnyi
Maybe this question was answered, but I did not find it.
So that's why? so
Code: Select all
PostEvent (Event[, Window, Object]...)
not so
Code: Select all
PostEvent (Event[, Window[, Object]]...)