How To Find mouseX/Y

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

How To Find mouseX/Y

doug777
In my old Container or Group type objects I used to be able to say -

pos = this.mouseX (or Y)

But how to find the mouse position in Royale layout containers?

Doug



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

Gabe Harbs
We don’t have an equivalent yet.

The problem in HTML is that the only way to get mouse position is from a mouse event. The best way to do that is add a mouse move listener to the app and store the values. Something like this: https://stackoverflow.com/a/7790764

Once you have the global coordinates, you can use PointUitls.globalToLocal() to convert that to local coordinates.

HTH,
Harbs

> On Feb 26, 2018, at 11:05 AM, doug777 <[hidden email]> wrote:
>
> In my old Container or Group type objects I used to be able to say -
>
> pos = this.mouseX (or Y)
>
> But how to find the mouse position in Royale layout containers?
>
> Doug
>
>
>
> --
> Sent from: http://apache-royale-users.20374.n8.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

doug777
Okay I see what you mean. I'll find a way to do that.

Many thanks for your help.

Doug



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

Alex Harui-2
Packaging up some code as a bead that listens to the mouse, remembers the
last event and can then be asked for the position in a component would be
a great thing.

One question though:  What is the scenario where you are trying to
determine the position of the mouse that isn't somehow already driven by a
mouse event?

Just wondering...
-Alex

On 2/26/18, 1:24 AM, "doug777" <[hidden email]> wrote:

>Okay I see what you mean. I'll find a way to do that.
>
>Many thanks for your help.
>
>Doug
>
>
>
>--
>Sent from:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-roy
>ale-users.20374.n8.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7Cc494d
>ce62b9e45976b3b08d57cfad12d%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>36552339066881905&sdata=o8m0vuHbNxLtvBlhSueUXUVJNiIbGPFgrSbbDPJvjmg%3D&res
>erved=0

Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

Gabe Harbs
I needed to do something similar in my app.

I have a lot of transformed SVG elements and mouse events when attached to the elements did not fire correctly. Instead of attaching event listeners to individual elements, I’m attaching a global mousemove listener to the whole app background and calculating which element is below the mouse.

Harbs

> On Feb 26, 2018, at 5:41 PM, Alex Harui <[hidden email]> wrote:
>
> Packaging up some code as a bead that listens to the mouse, remembers the
> last event and can then be asked for the position in a component would be
> a great thing.
>
> One question though:  What is the scenario where you are trying to
> determine the position of the mouse that isn't somehow already driven by a
> mouse event?
>
> Just wondering...
> -Alex
>
> On 2/26/18, 1:24 AM, "doug777" <[hidden email]> wrote:
>
>> Okay I see what you mean. I'll find a way to do that.
>>
>> Many thanks for your help.
>>
>> Doug
>>
>>
>>
>> --
>> Sent from:
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-roy
>> ale-users.20374.n8.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7Cc494d
>> ce62b9e45976b3b08d57cfad12d%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>> 36552339066881905&sdata=o8m0vuHbNxLtvBlhSueUXUVJNiIbGPFgrSbbDPJvjmg%3D&res
>> erved=0
>

Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

doug777
In reply to this post by Alex Harui-2
Hi Alex,

The mouse event starts a 500ms timer and when the timer ends I find out if
the mouse is still over the same element. This prevents things flickering on
and off as you move the mouse over the page, but gives the desired result if
you hover for at least that long on the same element.

Even so I can't see how to get the mouse position from the Royale Mouse
Event either.

So a mouse position bead would be great.

Doug



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

Alex Harui-2
Hi Doug,

Royale MouseEvent should have clientX/Y and localX/Y properties.  However,
I would recommend trying to keep track of mouseOver/mouseOut and/or
rollOver/rollOut events.  In fact, I'd be tempted to kill the timer on
mouseOut if that makes sense for your UX.

IOW, I'm not sure whether you care about the actual position, or just
whether it is "over" or "out".

HTH,
-Alex

On 2/26/18, 5:41 PM, "doug777" <[hidden email]> wrote:

>Hi Alex,
>
>The mouse event starts a 500ms timer and when the timer ends I find out if
>the mouse is still over the same element. This prevents things flickering
>on
>and off as you move the mouse over the page, but gives the desired result
>if
>you hover for at least that long on the same element.
>
>Even so I can't see how to get the mouse position from the Royale Mouse
>Event either.
>
>So a mouse position bead would be great.
>
>Doug
>
>
>
>--
>Sent from:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-roy
>ale-users.20374.n8.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7C47ced
>105e0754b402a1a08d57d833145%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>36552924780253114&sdata=vwp7R3AzHcL%2FNNb1PuUUnxtlxe4UVZLdSswntyF0M9w%3D&r
>eserved=0

Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

doug777
Hi Alex,

Yes that's the answer. Keep track of the local or client XYs and use the
most recent one if any timer gets to time out.

I don't want to give up the timer otherwise the mouse over or roll over
event starts the change that then gets killed when you mouse or roll out.
This causes an ugly flickering mess if you move the mouse about over the
page. Once the mouse is out of an object that timer is killed and nothing
happens visibly.

Thanks very much for the solution.
Doug



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

Piotr Zarzycki
Doug,

It could be great start for you with helping evolve Royale write Bead for Mouse X/Y listening :) It could be part of Royale framework.

Thanks,
Piotr



2018-02-27 10:34 GMT+01:00 doug777 <[hidden email]>:
Hi Alex,

Yes that's the answer. Keep track of the local or client XYs and use the
most recent one if any timer gets to time out.

I don't want to give up the timer otherwise the mouse over or roll over
event starts the change that then gets killed when you mouse or roll out.
This causes an ugly flickering mess if you move the mouse about over the
page. Once the mouse is out of an object that timer is killed and nothing
happens visibly.

Thanks very much for the solution.



--

Piotr Zarzycki 

Patreon: https://www.patreon.com/piotrzarzycki

Reply | Threaded
Open this post in threaded view
|

Re: How To Find mouseX/Y

doug777
Hi Piotr,

I would love to do it, but not sure I have the necessary skill.

But if you can point me towards how to get started, I'll certainly give it
my best shot.

Doug



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/