Hi.
I would like to know if it's possible to add a mouse handler on a specific morph ? I have a window and i would like to know the position of my mouse only in this window. For exemple i also use : self on: #mouseDown send: #captureMouse: to: self. But it give me the mouse position in pharo environment and not only in my window.
Thanks :) Douaille Erwan <[hidden email]> |
This is because, under rare circumstances, it is desirable to do
something in/on/to the desktop based on the position in the local morph. To get the local coordinates look for a method with the word "global" in it -- globalToLocal: or something like that. It's in Squeak, not sure whether this is still in Pharo though.. If anything, you could always just subtract the upperleft coordinate of your window from the MouseEvent's position.. On Wed, May 2, 2012 at 9:02 AM, Erwan Douaille <[hidden email]> wrote: > Hi. > > I would like to know if it's possible to add a mouse handler on a specific > morph ? > I have a window and i would like to know the position of my mouse only in > this window. > > For exemple i also use : > > self on: #mouseDown send: #captureMouse: to: self. > > But it give me the mouse position in pharo environment and not only in my > window. > > > Thanks :) > > -- > Douaille Erwan <[hidden email]> |
In reply to this post by Erwan Douaille
Erwan
I guess that you should get the mouse position and the window corner and compute the coordinates by yourself. World activeHand position Stef > Hi. > > I would like to know if it's possible to add a mouse handler on a specific morph ? > I have a window and i would like to know the position of my mouse only in this window. > > For exemple i also use : > > self on: #mouseDown send: #captureMouse: to: self. > > But it give me the mouse position in pharo environment and not only in my window. > > > Thanks :) > > -- > Douaille Erwan <[hidden email]> |
In reply to this post by Chris Muller-3
Okay, but i didn't find anything with globalToLocal. And i've find another solution, just use soustraction for this problem :
captureMouse: event Transcript cr;show: event position - self position.
That's work too :) Thanks ;) 2012/5/2 Chris Muller <[hidden email]> This is because, under rare circumstances, it is desirable to do Douaille Erwan <[hidden email]> |
Hi,
I guess that properly you should do:
(self globalPointToLocal: event
position) - self position
which should deal with the case of being embedded
in a scroll pane or other transform
Regards, Gary
|
Free forum by Nabble | Edit this page |