You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Harbs <ha...@gmail.com> on 2021/02/24 13:55:18 UTC

MouseEvent.buttonDown

In trying to figure out why something was not working in my app, I discovered that I believe the code in MouseEvent.buttonDown is wrong.

MouseEvent has the following code:

public function get buttonDown():Boolean
{
    return button > -1 && button < 3;
}

While BrowserEvent has the following more complex code:
public function get buttonDown():Boolean
{
    if(_buttons > -1)
        return _buttons == 1;
    var ev:* = wrappedEvent.getBrowserEvent();
    //Safari does not yet support buttons
    if ('buttons' in ev)
        return ev["buttons"] == 1;
    return ev["which"] == 1;
}

AIUI, button while never be -1. Both the left button and no button will be 0.

There’s also a difference in proposed behavior. In MouseEvent, any button would theoretically return true, while BrowserEvent will only return true if the left button is pressed.

Any objections to changing MouseEvent to match BrowserEvent?

Thanks,
Harbs

Re: MouseEvent.buttonDown

Posted by Carlos Rovira <ca...@apache.org>.
Hi Harbs,

just try with different examples and in mobile browsers to check it works
as expected, and change if you thing we improve over older code.
I remember problems with particular button configuration in mobile
browsers, and could be related to this, but can't now remember exactly what
was about.

El mié, 24 feb 2021 a las 14:55, Harbs (<ha...@gmail.com>) escribió:

> In trying to figure out why something was not working in my app, I
> discovered that I believe the code in MouseEvent.buttonDown is wrong.
>
> MouseEvent has the following code:
>
> public function get buttonDown():Boolean
> {
>     return button > -1 && button < 3;
> }
>
> While BrowserEvent has the following more complex code:
> public function get buttonDown():Boolean
> {
>     if(_buttons > -1)
>         return _buttons == 1;
>     var ev:* = wrappedEvent.getBrowserEvent();
>     //Safari does not yet support buttons
>     if ('buttons' in ev)
>         return ev["buttons"] == 1;
>     return ev["which"] == 1;
> }
>
> AIUI, button while never be -1. Both the left button and no button will be
> 0.
>
> There’s also a difference in proposed behavior. In MouseEvent, any button
> would theoretically return true, while BrowserEvent will only return true
> if the left button is pressed.
>
> Any objections to changing MouseEvent to match BrowserEvent?
>
> Thanks,
> Harbs



-- 
Carlos Rovira
Apache Member & Apache Royale PMC
*Apache Software Foundation*
http://about.me/carlosrovira