Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 28 Jan 2010 08:36:27 -0000
I have used "InstallEventHandler()" to react on mouse clicks anywwhere on the display. In addition, I have some buttons, created with MakeButton(..,#SIMPLEBUTTON,..), which also should react on mouse clicks.
Now, with HW4.5, even if i click on the button, the event handler installed by "InstallEventHandler()" is triggered and not that one installed with MakeButton(). If i click freqently enough on the button, at some point the button-event-handler is triggered. However, it *seems* that always the events installed by "InstallEventHandler()" are served first?
In HW4.0 a click on a button triggered only the MakeButton()-Event.
I wonder now, how my event handler should distinguish between clicks from buttons and other clicks and how to prevent event triggers from other events if a button event should be triggered?
I only see to use a global variable which is set when the mouse triggeres "OnMouseOver"-event and then if a click-event appears, it has to be a button event, but this doesn't solve the need for "msg.userdata" which is not correctly set, if the eventhandler is executed installed by "InstallEventHander()".
Is this a bug (also maybe in my code, but in HW4.0 it worked perfectly the way it is) or is there a reason for this behavior?
Am I *really* the only one who used accidently all these things which changed from HW4.0 to HW4.5?
regards, Tom
[28 Jan 2010] Event handling has changed in HW4.5, too?
[28 Jan 2010] Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 28 Jan 2010 16:43:43 -0000
After some more tests, I think, this is a bug in HW4.5? (Or I simple don't understand why a click on a button triggers the event handler, which was installed by InstallEventHandler(), but not the button's event handler, installed by MakeButton()).
Can someone confirm this?
Thanks, Tom
P.S. My event handler does the following workarround. As soon as the mouse moves over a button, the "msg.userdate" is stored in a global variable, leaves the mouse the button again, that variable is set to nil. If a Mouse click happens, than the event handler checks the global variable to decide if it was a click on a button or not. In this way, the button's own even handler becomes superfluous.
After some more tests, I think, this is a bug in HW4.5? (Or I simple don't understand why a click on a button triggers the event handler, which was installed by InstallEventHandler(), but not the button's event handler, installed by MakeButton()).
Can someone confirm this?
Thanks, Tom
P.S. My event handler does the following workarround. As soon as the mouse moves over a button, the "msg.userdate" is stored in a global variable, leaves the mouse the button again, that variable is set to nil. If a Mouse click happens, than the event handler checks the global variable to decide if it was a click on a button or not. In this way, the button's own even handler becomes superfluous.
[28 Jan 2010] Re: Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 28 Jan 2010 21:12:53 +0100
That's very, very strange. In my Sprite Creator program, I'm using a system exactly similar to what you are describing, with a separate event handler for buttons and one for mouse clicks, and here the button events always come first. I just updated to HW 4.5, and it still works for me, so there must be something wrong with your script, or you must be triggering some very odd and rare bug in HW. What kind of system are you using? In which order are you installing the event handlers, buttons first or mouse clicks first? Are you maybe accidentally installing the event handlers multiple times or .... ??? I don't know what else to suggest...
Best,
Alfkil
That's very, very strange. In my Sprite Creator program, I'm using a system exactly similar to what you are describing, with a separate event handler for buttons and one for mouse clicks, and here the button events always come first. I just updated to HW 4.5, and it still works for me, so there must be something wrong with your script, or you must be triggering some very odd and rare bug in HW. What kind of system are you using? In which order are you installing the event handlers, buttons first or mouse clicks first? Are you maybe accidentally installing the event handlers multiple times or .... ??? I don't know what else to suggest...
Best,
Alfkil
[28 Jan 2010] Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 28 Jan 2010 22:09:07 +0100

I have to check, if this could be a problem in my script. But actually, I think, i clear each event handler before installing another one (which I do at some points).
Thanks for that response, it triggers a potential error source in my script?
However, strange that it works in HW4.0. Maybe i should write a test script which just installs a evenhandler for clicks on display and one for a button click.
Thanks, Tom
At least in HW4.0 it workedbe something wrong with your script, or you must be triggering some very odd and rare bug in HW.
A handler for mouse clicks on the display is installed first, but is the order important at all?What kind of system are you using? In which order are you installing the event handlers, buttons first or mouse clicks first?
Is that a problem either? Isn't one handler replaced by the next one?Are you maybe accidentally installing the event handlers multiple times or .... ???
I have to check, if this could be a problem in my script. But actually, I think, i clear each event handler before installing another one (which I do at some points).
Thanks for that response, it triggers a potential error source in my script?
However, strange that it works in HW4.0. Maybe i should write a test script which just installs a evenhandler for clicks on display and one for a button click.
Thanks, Tom
- airsoftsoftwair
- Posts: 5914
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[28 Jan 2010] Re: Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 28 Jan 2010 23:08:36 +0100
The "global variable" solution is not good. I'm not sure if I understood your problem correctly. What I can say, though, is that you won't be able to distinguish between buttons and display presses because in Hollywood 4.5 displays will also pass an "ID". But you can use "UserData" to do this, e.g.
Yes, please give us a small test script and then we'll see what's wrong thereThanks for that response, it triggers a potential error source in my script?
However, strange that it works in HW4.0. Maybe i should write a test script which just installs a evenhandler for clicks on display and one for a button click.
Code: Select all
Function p_func(msg)
If msg.userdata = 1
DebugPrint("Button")
Else
DebugPrint("Display")
EndIf
EndFunction
MakeButton(1, #SIMPLEBUTTON, 0, 0, 100, 100, {OnMouseDown = p_Func}, 1)
InstallEventHandler({OnMouseDown = p_Func}, 0)
Repeat
WaitEvent
Forever
[29 Jan 2010] Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 29 Jan 2010 09:35:25 -0000
Hi Andreas,
thanks for your response.
ok, i made an example script (actually similar to the one you did below -- see below). It shows that the event handler, that is installed by "InstallEventHandler()", is executed first and always if you click on a button. That seemed to be not the case in HW4.0.
Is this a bug in HW4.5 or why are both eventhandler triggered?
My (real) script switches from one slide to the next if i receive a non-button mouse-click event. For this, it clears all layers first and all buttons are newly created. It seems that the button event is then lost completely -- at least, that could be an explanation for why i rarely got a button event at all in my real script (and only by clicking frequently on a button).
regards, Tom
Hi Andreas,
thanks for your response.
ok, i made an example script (actually similar to the one you did below -- see below). It shows that the event handler, that is installed by "InstallEventHandler()", is executed first and always if you click on a button. That seemed to be not the case in HW4.0.
Is this a bug in HW4.5 or why are both eventhandler triggered?
Code: Select all
@VERSION 4,5
@DISPLAY { Width=640, Height=480, Color = #BLACK, Title = "test"}
Function p_event(msg)
cnt=cnt+1
Switch msg.action
Case "OnMouseOver"
;DebugPrint("OnMouseOver")
Case "OnMouseOut"
;DebugPrint("OnMouseOut")
Case "OnMouseUp"
If msg.userdata = "button"
mclicks=mclicks+1
DebugPrint("button click: "..mclicks)
EndIf
If msg.userdata = "display"
dclicks=dclicks+1
DebugPrint("click on display: "..dclicks)
EndIf
Default:
DebugPrint("unsupported action: "..msg.action)
EndSwitch
EndFunction
EnableLayers()
CreateBGPic(1, 640, 480, #GRAY)
DisplayBGPic(1)
SelectBGPic(1)
Box(50,50,100,100,#RED)
MakeButton(nil,#SIMPLEBUTTON,50,50,100,100,
{/*OnMouseOver=p_event,OnMouseOut=p_event,*/
OnMouseUp=p_event},"button")
InstallEventHandler({OnMouseUp=p_event},"display")
EndSelect()
cnt=0
mclicks=0
dclicks=0
Repeat
DebugPrint("Wait for event: "..cnt)
WaitEvent
;DebugPrint("----------------- Event done")
Forever
regards, Tom
- airsoftsoftwair
- Posts: 5914
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[31 Jan 2010] Re: Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 31 Jan 2010 22:00:23 +0100
Well, it's a bug in 4.0 because that didn't send you an OnMouseDown in case it happened over a button. OnMouseDown is designed to trigger whenever the mouse is pressed over the window. It's running independent from any buttons...Hi Andreas,
thanks for your response.
ok, i made an example script (actually similar to the one you did below -- see below). It shows that the event handler, that is installed by "InstallEventHandler()", is executed first and always if you click on a button. That seemed to be not the case in HW4.0.
Is this a bug in HW4.5 or why are both eventhandler triggered?
[03 Feb 2010] Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 03 Feb 2010 07:55:18 +0100
Thanks, Tom
But I had not "OnMouseDown"-Event installed (neither with InstallEventHandler() nor with MakeButton()) but only for "MouseButtonUp"-Event. And that event is triggerd twice if you click on a button (as demonstrated in the example I gave here) -- first because of InstallEventHandler() (and that should not happen, right?) and afterwards due to the MakeButton()-Functions (which should be the only routine which is executed, right?)Well, it's a bug in 4.0 because that didn't send you an OnMouseDown in case it happened over a button. OnMouseDown is designed to trigger whenever the mouse is pressed over the window. It's running independent from any buttons...
Thanks, Tom
- airsoftsoftwair
- Posts: 5914
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[05 Feb 2010] Re: Re: Event handling has changed in HW4.5, too?
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 05 Feb 2010 21:31:48 +0100
I accidentally spoke of "OnMouseDown" but in your case it's "OnMouseUp" of course. But the behaviour is right because when you install "OnMouseDown" or "OnMouseUp" globally on a display, you will always get these events when the mouse button goes down or up... even if there's a button occupying this area. Buttons are a highlevel API, querying display events directly is the lowlevel API 
No, it's correct behaviour the way it isBut I had not "OnMouseDown"-Event installed (neither with InstallEventHandler() nor with MakeButton()) but only for "MouseButtonUp"-Event. And that event is triggerd twice if you click on a button (as demonstrated in the example I gave here) -- first because of InstallEventHandler() (and that should not happen, right?) and afterwards due to the MakeButton()-Functions (which should be the only routine which is executed, right?)