Create & Edit a PushButton in a ViewComposer

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

Create & Edit a PushButton in a ViewComposer

Howard Oh
Hi,

I would like to contribute a small goodie code patch for ViewComposer
that can increase your velocity of your GUI project.

Many visual IDE's of today provides a "Double click and edit that
button." feature.

I think Dolphin Smalltalk can have that hand off.

modify ViewComposer>>createSchematicWiring to let ViewComposer react to
user's double click in the arena.
---------------------------------------------------------------------------------------
ViewComposer>>createSchematicWiring

               ......................
                ......................
        arenaPresenter
                when: send: to;
                when: send: to;
                when: send: to;
                when: send: to;
                                ......................
                when: #actionPerformed
                        send: #onArenaDoubleClicked
                        to: self.
                ......................
                ......................
---------------------------------------------------------------------------------------


And then,  create a new method by compiling below.
---------------------------------------------------------------------------------------
ViewComposer>>onArenaDoubleClicked


        | owningPresenterClass commandSymbol |
        self resourceIdentifier name isNil
                ifTrue: [ ^MessageBox errorMsg: 'Save this view before editing
command method.' ].

        owningPresenterClass := self resourceIdentifier owningClass.
        [ commandSymbol := inspector model value commandDescription command ]
                on: Error
                do: [:exp| "silent exit"^self ].
        commandSymbol isNil
                ifTrue:
                [ ^MessageBox errorMsg: 'Assign command symbol before editing command
method.' ].

        (owningPresenterClass canUnderstand: commandSymbol)
                ifFalse:
                [ owningPresenterClass compile: commandSymbol. "creating method" ].

        (owningPresenterClass compiledMethodAt: commandSymbol) browse
---------------------------------------------------------------------------------------

Have a good one
Howard