Making a Rubric text morph movable

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

Making a Rubric text morph movable

Stephan Eggermont-3
We have a Morph containing a RubTextFieldMorph that we want
to be able to drag around. At the same time, we want selection
extension with the mouse to work. That feels ok when the dragging
can only be initiated when the text field has no keyboard focus.

The way we've made that work feels somewhat clumsy.
What would be a better way?

The containing morph has a default mouseDownPriority of 10

MindmapNode>>initialize
        super initialize.
        self addMorph: (
        (MindmapTextField
                on: self)
                withGhostText: self defaultTitle;
                autoAccept: true;
                bounds: (self bounds);
                yourself).
        prio := 10.

When it is clicked, the prio is set to 0

MindmapNode>>click: evt
        submorphs first takeKeyboardFocus.
        prio := 0

The text field is subclassed

RubTextFieldMorph subclass: #MindmapTextField

and overrides whenFocusLost:

MindmapTextFieldwhenLostForcus: anAnnouncement
        owner resetPrio.
        super whenLostForcus: anAnnouncement


MindmapNode>>resetPrio
        prio := 10

Noah & Stephan