CS 683 Emerging Technologies: Embracing Change Spring Semester, 2001 Perform & Menu |
||
---|---|---|
© 2001, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 05-Apr-01 |
Symbols
A symbol is formed by:
'cat' == 'tac' reversed
'cat' asSymbol == 'tac' reversed asSymbol
perform: aSymbol
Object implements perform: aSymbol
perform: aSymbol
Action |
Result |
'cat' perform: #reversed |
tac |
'cat' perform: #at: with: 1 |
$c |
'cat' perform: 'reversed' asSymbol |
'tac' |
3 perform: #+ with: 2 |
5 |
'smalltalk' perform: #copyFrom:to: with: 6 with: 9 |
'talk' |
'smalltalk' perform: #copyFrom:to: withArguments: #( 6 9 ) |
'talk' |
Simple Dialog
FillInTheBlankMorph returns
FillInTheBlankMorph request: 'Type something'
FillInTheBlankMorph request: 'Type something' initialAnswer: 'Yes'
FillInTheBlankMorph requestPassword: 'Password?'
Popup Menus
Menus have
Some Menu methodsInstance Creation MenuMorph new MenuMorph entitled: 'Popup'
Instance method
add: aDisplayString target: anObject selector: aSymbol add: aString target: anObject selector: aSymbol argument: anObject add: aString target: target selector: aSymbol argumentList: array add: aString subMenu: aMenu.
add: aString action: aSymbol add: aString selector: aSymbol add: aString selector: aSymbol argument: anObject
defaultTarget: anObject
position: aPoint
addStayUpItem
Simple Example
| menu nestedMenu | nestedMenu := MenuMorph new. nestedMenu add: 'Bye' target: Transcript selector: #show: argument: 'bye'. menu := MenuMorph entitled: 'Popup'. menu addStayUpItem. menu add: 'Transcript open' target: Transcript selector: #open. menu add: 'Hi' target: Transcript selector: #show: argument: 'hi'. menu add: 'More...' subMenu: nestedMenu. menu openInWorld
Example with Real Target
| menu | menu := MenuMorph entitled: 'My Title'. menu addStayUpItem; defaultTarget: MenuModelExample new. menu add: 'left' action: #left. menu add: 'right' action: #right. menu addLine. menu addLine. "extra lines ignored" menu add: 'Say Hi' selector: #displayMessage: argument: 'hi'. menu addLine. menu add: 'Transcript open' target: Transcript action: #open. menu add: 'Transcript show' target: Transcript selector: #show: argument: 'hi'. menu addLine. menu openInWorld
MenuModelExample
Object subclass: #MenuModelExample instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Whitney-Examples' displayMessage: aString Transcript show: aString; cr.! ! left self displayMessage: 'left called' right self displayMessage: 'right called'
Copyright ©, All rights reserved.
2001 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.
Previous    visitors since 05-Apr-01    Next