WebElement>>onClickDo: aBlock andUpdate: anElement

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

WebElement>>onClickDo: aBlock andUpdate: anElement

Alex Baran
Hello Aida community,

I have modified Aida, so now you can evaluate block if user click on an element.
I think example can tell more than words. Let implement counter:

viewCounter
        | e inc counterElement dec |
        e := WebElement new.
        inc := e addText: '++'.
        dec := e addText: '--'.
        counterElement := e add: self counterElement.
        inc
                onClickDo: [counter := counter + 1]
                andUpdate: counterElement.
        dec
                onClickDo: [counter := counter - 1]
                andUpdate: counterElement.
        self
                pageFrameWith: e
                title: ''

counterElement
        | e |
        e := WebElement new.
        e addText: 'Counter: ', counter displayString.
        ^e


During modification one Aida method was changed, the rest of the
modifications is just new methods.
Code is availavle in two variants: VW parcel, and .st file so it can
be manually transfered(copy text of 5 methods) to Squeak. My Aida is
5.6.0.
It just first attempt intended to know if this way of handling events
is of interest, so don't except much(or any) stability from the code.
I wanted to post code to the Cincom public store, but was unsure about
how to name the package to not clutter other Aida packages.
My next post will be example of master-details grids relationship,
which together with counter example you can be find in Aida-BlocksDemo
(will be attached to next post).


Alex

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida

Aida-Blocks.pcl (3K) Download Attachment
Aida-Blocks.pst (6K) Download Attachment
Aida-Blocks.st (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: WebElement>>onClickDo: aBlock andUpdate: anElement

Alex Baran
Master-details grid example.

When element clicked in master grid, details will update according to selection.

viewMasterDetail>viewMasterDetail
        | master detail e |
        subcollection := Array new.
        collection := Array
                with: #fruits -> #(#apple #orange #limon)
                with: #vegetables -> #(#potato #cabbage).

        e := WebElement new.

        master := e add: WebGrid new.
        e addBreak.
        detail := e add: self detailGrid.

        master
                columnNames: #('Plant');
                columnAspects: #(#displayString);
                collection: collection;
                column: 1 addBlock:
                                [:each |
                                (WebText new text: each key)
                                        onClickDo: [subcollection := each value]
                                        andUpdate: detail].

        self pageFrameWith: e title: ''

detailGrid
        | grid e |
        e := WebElement new.
        grid := e add: WebGrid new.
        grid
                columnNames: #('Names');
                columnAspects: #(displayString);
                collection: subcollection.



Reply | Threaded
Open this post in threaded view
|

Re: WebElement>>onClickDo: aBlock andUpdate: anElement

Alex Baran
Parcel with examples

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida

Aida-BlocksDemo.pcl (3K) Download Attachment
Aida-BlocksDemo.pst (6K) Download Attachment