Sha256: 1906979a76c89478f00c11eae8b80fecf6e8a532eebcf4359cfd061284553c38

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

Smalltalk current createPackage: 'Examples' properties: #{}!
Widget subclass: #Counter
	instanceVariableNames: 'count header'
	package: 'Examples'!
!Counter commentStamp!
This is a trivial Widget example mimicking the classic Counter example in Seaside. 
In order to play with it, just select the doit below and press the Do it button in the far right corner.
Then take a look in the HTML document above the IDE.

        Counter new appendToJQuery: 'body' asJQuery!

!Counter methodsFor: 'actions'!

decrease
    count := count - 1.
    header contents: [:html | html with: count asString]
!

increase
    count := count + 1.
    header contents: [:html | html with: count asString]
! !

!Counter methodsFor: 'initialization'!

initialize
    super initialize.
    count := 0
! !

!Counter methodsFor: 'rendering'!

renderOn: html
    header := html h1 
	with: count asString;
	yourself.
    html button
	with: '++';
	onClick: [self increase].
    html button
	with: '--';
	onClick: [self decrease]
! !

!Counter class methodsFor: 'example'!

tryExample
	"In order to play with the Counter, just select the
	doit below and press the Do it button. Then take a
	look in the HTML document above the IDE."

	"Counter tryExample"
        self new appendToJQuery: 'body' asJQuery
! !

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
resin-0.4.0 amber/st/Examples.st
resin-0.3.1 amber/st/Examples.st
resin-0.3.0 amber/st/Examples.st
resin-0.2.3 amber/st/Examples.st
resin-0.2.2 amber/st/Examples.st