It is currently Mon Nov 20, 2017 1:09 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: What is PostEvent() window # without optional paramater
PostPosted: Wed Nov 18, 2015 8:16 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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:
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

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Wed Nov 18, 2015 9:29 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13141
Location: France
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Wed Nov 18, 2015 5:09 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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.

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Wed Nov 18, 2015 6:51 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 6:41 pm
Posts: 1355
Maybe a new konstant #pb_windowid_broadcast would be a solution.


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Wed Nov 18, 2015 9:07 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 604
Quote:
May be it would be better to use #PB_All as default value

That would be correct.


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Wed Nov 18, 2015 9:19 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1471
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Thu Nov 19, 2015 6:18 am 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 2916
Location: Planet Earth
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


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Thu Nov 19, 2015 8:45 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 604
Quote:
-1 is already used internally for non-valid events, so I think it's good to use -1 there as well

I agree
Quote:
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: What is PostEvent() window # without optional paramater
PostPosted: Sun Oct 08, 2017 8:59 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 604
Maybe this question was answered, but I did not find it.
So that's why? so
Code:
PostEvent (Event[, Window, Object]...)

not so
Code:
PostEvent (Event[, Window[, Object]]...)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye