Page 1 of 1

Event handling problem

Posted: Sun Jan 27, 2013 5:53 pm
by Mazze

in HollyPaint I'm using a Hollywood object within a scrollgroup/virtgroup. To get mouse clicks in the Hollywood object I have added a traditional Hollywood button with event handlers. That doesn't work well anymore since HollyPaint has become a multi window application [1].

If I click a gadget in the toolbar window [2] and then click into the canvas window a MouseX call within the event handler returns sometimes a negative value. That causes crashes because some graphics functions can't deal with negative values. There is probably a conflict between MUI [3] and Hollywood event handler. Catching negative variables isn't an option because toolbar and canvas window can overlap.

Source code is here: ... ree/trunk/

[2] in reality it's enough to activate the toolbar window
[3] it's Zune under AROS in case it matters

Re: Event handling problem

Posted: Tue Jan 29, 2013 5:58 pm
by airsoftsoftwair
Does this problem go away if you use a normal group instead of a virtgroup/scrollgroup?

Re: Event handling problem

Posted: Tue Jan 29, 2013 10:24 pm
by Mazze
Nope, didn't help.

The problem doesn't happen if a manually activate the canvas window before clicking in it.

Re: Event handling problem

Posted: Wed Jan 30, 2013 5:17 pm
by airsoftsoftwair
Ok, can you make a very small example test case? Then I can check this issue.

Re: Event handling problem

Posted: Wed Jan 30, 2013 8:34 pm
by Mazze
It turned out that it isn't necessary to have a 2nd window. Just click somewhere on the desktop to deactivate the MUI window, then click again in the window. I get always an alert message. If I activate the window before clicking in it the coordinates are correct.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>

<application base="hollypaint" id="app">
    <window id="canvas_window" title="Unnamed" notify="closerequest">
            <hollywood id="hwmcc1" display="1" />

Code: Select all

@DISPLAY {Width = 320, Height = 200, Hidden = True}

Function p_EventFunc(msg)
    DebugPrint("****" .. msg.action)

    Switch msg.action
    Case "MUIRoyale":
        Switch msg.Attribute
        Case "CloseRequest":


Function p_MouseDown()
    Local mx = MouseX()
    Local my = MouseY()
    If mx < 0 or mx > 320 or my < 0 or my > 200
        DebugPrint("***** ALERT *****")
    DebugPrint("Down " .. MouseX() .. " " .. MouseY())

InstallEventHandler({MUIRoyale = p_EventFunc})

MakeButton(1, #SIMPLEBUTTON, 0, 0, 320, 200, {OnMouseDown = p_MouseDown})


Re: Event handling problem

Posted: Sat Feb 02, 2013 6:08 pm
by airsoftsoftwair
I cannot reproduce this on OS3, OS4 and MorphOS so it looks like a Zune issue.

Re: Event handling problem

Posted: Sun Feb 03, 2013 5:17 am
by Mazze
Ouch. Do you have an idea what's missing in Zune?

Re: Event handling problem

Posted: Sun Feb 03, 2013 12:12 pm
by airsoftsoftwair
Well, it seems that Zune forwards IDCMP events to the custom class where IntuiMessage.MouseX and IntuiMessage.MouseY are smaller than the _mleft() and _mtop() offsets of the MUI object. MUI Royale subtracts _mleft(obj) from IntuiMessage.MouseX and _mtop(obj) from IntuiMessage.MouseY and then injects these relative coordinates into Hollywood's event handler. So if you get negative coordinates for MouseX() or MouseY(), then the IntuiMessage that is sent to the MUI object by Zune contains some bogus values where IntuiMessage.MouseX or IntuiMessage.MouseY are smaller than _mleft() or _mtop() respectively.