Event handling problem

Discuss GUI programming with the MUI Royale plugin here
Post Reply
Mazze
Posts: 69
Joined: Thu May 06, 2010 8:08 pm

Event handling problem

Post by Mazze »

Hi,

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: https://sourceforge.net/p/hollypaint/co ... ree/trunk/

[1] http://www.mazze-online.de/hollypaint/hollypaint2.png
[2] in reality it's enough to activate the toolbar window
[3] it's Zune under AROS in case it matters
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post by airsoftsoftwair »

Does this problem go away if you use a normal group instead of a virtgroup/scrollgroup?
Mazze
Posts: 69
Joined: Thu May 06, 2010 8:08 pm

Re: Event handling problem

Post by Mazze »

Nope, didn't help.

The problem doesn't happen if a manually activate the canvas window before clicking in it.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post by airsoftsoftwair »

Ok, can you make a very small example test case? Then I can check this issue.
Mazze
Posts: 69
Joined: Thu May 06, 2010 8:08 pm

Re: Event handling problem

Post 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">
        <hgroup>
            <hollywood id="hwmcc1" display="1" />
        </hgroup>
    </window>
</application>

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":
            End

        EndSwitch
    EndSwitch
EndFunction

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

InstallEventHandler({MUIRoyale = p_EventFunc})
mui.CreateGui(FileToString("hollypaint.xml"))

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

Repeat
    WaitEvent
Forever
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post by airsoftsoftwair »

I cannot reproduce this on OS3, OS4 and MorphOS so it looks like a Zune issue.
Mazze
Posts: 69
Joined: Thu May 06, 2010 8:08 pm

Re: Event handling problem

Post by Mazze »

Ouch. Do you have an idea what's missing in Zune?
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post 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.
Post Reply