[Cuis] mouseButton2Up:localPosition:

Dan Norton dnorton at mindspring.com
Wed Apr 29 09:45:22 CDT 2015


On 27 Apr 2015 at 8:10, Juan Vuletich wrote:

> Hi Dan,
> 
> So, where's the bug? It's in your #mouseButton2Up:localPosition: .
> You get
> a point in local coordinates (you can check this bu just adding
> 'localEventPosition print'). And you ask for the menu to open there.
> But
> the menu is not a submorph. It will be a submorph of the world.
> (this is
> again easy to check by opening an inspector on the menu, by doing
> 'self
> inspect').
> 
Interesting. Please allow me to state my understanding of the case. When writing code for a 
Morph subclass, it's easy to assume that the "localPosition" refers to that of the receiver and 
it does. But PopUpMenu inherits from Object rather than Morph and when told to position 
itself 'at: localPosition', PopUpMenu has the display screen as its reference and interprets 
localPosition accordingly.

> What you want is, instead of just using 'localEventPosition' to use
> '(self
> externalizeToWorld: localEventPosition)'. 

#externalizeToWorld: transforms the parameter from the coordinates of self to the 
coordinates of the display screen. Using this as the location for PopUpMenu will cause it to 
appear over the top morph where the click occurred - the receiver.

Your alternative
> #xmouseButton2Activity is perfectly fine too.
> 

This gets "right to the point." Is this sent from MouseClickState>handleEvent:from: ?.

I hope I got all this right.

 - Dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150429/ba96e64c/attachment-0004.html>


More information about the Cuis mailing list