How to make a selector/list:
first go to scratch objects, scriptable scratch morph, instance, any op, and type
yourListName
^ #('your first list insert' 'your second list insert' 'your third list insert' 'etc.' )
Then you need to go to a new place you may have never gone. go to Scratch-Blocks, CommandBlockMorph, --- all ---, (scroll down to the second to last) uncoloredArgMorphFor:
you will see a lot of text, It will look like:
uncoloredArgMorphFor: t1
| t2 |
t2 _ t1 at: 2.
$a = t2 ifTrue: [^ AttributeArgMorph new choice: 'volume'].
$b = t2 ifTrue: [^ BooleanArgMorph new].
$c = t2 ifTrue: [^ ColorArgMorph new showPalette: true].
$C = t2 ifTrue: [^ ColorArgMorph new showPalette: false].
$d = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '0';
menuSelector: #directionMenu].
$D = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '48';
menuSelector: #midiDrumMenu].
$R = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #operatorNames;
choice: '+'].
$e = t2 ifTrue: [^ EventTitleMorph new].
$f = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #mathFunctionNames;
choice: 'sqrt'].
$g = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #graphicEffectNames;
choice: 'color'].
$j = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #engineNames;
choice: 'google'].
$H = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupSensorNames].
$h = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupBooleanSensorNames].
$I = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1';
menuSelector: #midiInstrumentMenu].
$i = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1';
menuSelector: #listIndexMenu].
$k = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #keyNames;
choice: 'space'].
$L = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #listVarMenu].
$l = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #costumeNames;
choice: 'costume1'].
$m = t2 ifTrue: [^ SpriteArgMorph new].
$M = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorNames].
$n = t2 ifTrue: [^ ExpressionArgMorph new numExpression: '10'].
$N = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '60';
menuSelector: #noteSelector].
$s = t2 ifTrue: [^ ExpressionArgMorph new stringExpression: ''].
$S = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #soundNames;
choice: 'pop'].
$v = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #varNamesMenu;
choice: ''].
$W = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorDirection].
$x = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #sceneNames;
choice: ''].
$y = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1';
menuSelector: #listIndexForDeleteMenu].
^ ExpressionArgMorph new numExpression: '10'
Now if you want a regular list that nothing will fit into (recommended) add:
$Your one letter(must not be one of the above letters) = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #yourListName;
choice: 'default choice'].].
right above the last line (^ ExpressionArgMorph new numExpression: '10')
If you wan't a number insert that also has a list (like direction or instrument) add:
$Your one letter(must not be one of the above letters) = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: 'default choice';
menuSelector: #yourListName].
right above the last line (^ ExpressionArgMorph new numExpression: '10')
If you want one that reporters can fit into (like the costume selector) add:
$Your one letter(must not be one of the above letters) = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #yourListName;
choice: 'default choice'].
right above the last line (^ ExpressionArgMorph new numExpression: '10')
Now when making your block put in block specs:
('%Your one letter' #type of block #codeToBlock:)
Did that help?
Last edited by Pecola1 (2010-12-27 10:57:17)
Offline