Event handling problem

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

Event handling problem

Post by Mazze » Sun Jan 27, 2013 6:53 pm

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: 2508
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post by airsoftsoftwair » Tue Jan 29, 2013 6:58 pm

Does this problem go away if you use a normal group instead of a virtgroup/scrollgroup?

Mazze
Posts: 61
Joined: Thu May 06, 2010 8:08 pm

Re: Event handling problem

Post by Mazze » Tue Jan 29, 2013 11:24 pm

Nope, didn't help.

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

User avatar
airsoftsoftwair
Posts: 2508
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post by airsoftsoftwair » Wed Jan 30, 2013 6:17 pm

Ok, can you make a very small example test case? Then I can check this issue.

Mazze
Posts: 61
Joined: Thu May 06, 2010 8:08 pm

Re: Event handling problem

Post by Mazze » Wed Jan 30, 2013 9:34 pm

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: 2508
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post by airsoftsoftwair » Sat Feb 02, 2013 7:08 pm

I cannot reproduce this on OS3, OS4 and MorphOS so it looks like a Zune issue.

Mazze
Posts: 61
Joined: Thu May 06, 2010 8:08 pm

Re: Event handling problem

Post by Mazze » Sun Feb 03, 2013 6:17 am

Ouch. Do you have an idea what's missing in Zune?

User avatar
airsoftsoftwair
Posts: 2508
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: Event handling problem

Post by airsoftsoftwair » Sun Feb 03, 2013 1:12 pm

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