How to get item under a menu?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to get item under a menu?

Adrian Kuhn
How can I get the item under a menu?

TestRunner is built with the ToolBuilder. The lists are specified with the
 pluggableListSpec and I can provide a selector that builds the menu. When
 building the menu I can add selector for the menu entries. As it seems, the
 item unter the menu is never known to me. Neither when building the menu nor
 when performing a menu item action.

So what I did is the following (an obvious hack)

    buildMenu: aMenu
        | morph index |
        morph := thisContext sender receiver;
        index := morph rowAtLocation: Sensor currentPoint.
        itemUnderMenu := list at: index ifAbsent: nil.
        itemUnderMenu ifNil: [ ^ aMenu ].
        ^ aMenu
            title: itemUnderMenu;
            add: 'action' action: #action;
            yourself

    action
        self performActionWith: itemUnderMenu

Can I get this done without a thisContext hack?

--AA


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project