Now what if you want your own dropdown? You may think this would need a lot of coding and lots of methods, but it's actually quite simple. First you will need to go to Scratch-Objects -> ScriptableScratchMorph ( or ScriptableSpriteMorph or ScriptableStageMorph, this time it doesn't matter which one.) Then go to any op (best to use sensing ops if you have a sensing list, sound ops for sound, etc. but it doesn't affect anything.) Now you will make your first code.
Make it like this:
yourNameForYourDroppdown
^ #('your first item' 'your second item' 'etc.' )Now go to Scratch-Blocks. Then switch to CommandBlockMorph. Now private. And finally uncoloredArgMorphFor:
This is where I got the list of inserts I gave you in chapter 2. You will see all of those letters on the side marked:
$oneLetter = t2 ifTrue: [].
Of course I could've just given you that and let you figure out how to find what goes to what but that would've taken longer for you.
To make your dropdown added add above the
^ ExpressionArgMorph new numExpression: '10'
:
$yourOneLetter = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #yourNameForYourDropdown].
THE yourOneLetter SHOULD NOT BE ANY OTHER LETTER USED FOR AN INSERT (you can use another case as in UPPERCASE or lowercase)
How about if you want it to have a default value?
$yourOneLetter = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #yourNameForYourDropdown; choice: 'your default choice'].
What if you want a reporter to fit into it?
$yourOneLetter = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #yourNameForYourDropdown;
choice: 'your default choice'].If you want it to be a number insert
$yourOneLetter = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: 'your default number';
menuSelector: #yourNameForYourDropdown].If you want a text insert
$yourOneLetter = t2 ifTrue: [^ ExpressionArgMorphWithMenu new stringExpression: 'your default string';
menuSelector: #listsMenu].DOES NOT ALWAYS WORK.
Now to test your dropdown, go to block specs (it doesn't matter which one, to test I use ScriptableScratchMorph) make your test block by simply inserting:
('%yourOneLetter' #- #-)
after 'control' (or any other place that names a category) accept. Go to the tab control (or whatever category you put it after) and find your block.
Example: 
Now let's make a block which includes a custom dropdown, here's a simple one: 
Using the information I have given you I want YOU to insert these codes where you think they should go (If you need help post about it):
Method:
reportSingle: t1
'infinity' = t1 ifTrue: [^ Float infinity].
'nil' = t1 ifTrue: [^ nil].
'pi' = t1 ifTrue: [^ Float pi].
'phi' = t1 ifTrue: [^ '1.61803399'].
'e' = t1 ifTrue: [^ Float e].
'newline' = t1 ifTrue: [^ String crlf].
'tab' = t1 ifTrue: [^ ' ']Method2:
singleNames
^ #('pi' 'phi' 'e' #- 'newline' 'tab' #- 'infinity' #- 'nil' )BlockSpecs:
('%A' #r #reportSingle:)
uncoloredArgMorphFor:
$A = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #singleNames].
Now go to the Operators category (or wherever you chose to put it), you have now made a new block! Of course you may have seen it in a mod or something, but this is one I have edited and made it look better, and more advanced. Can you add anything else to that list? Do you know how? It is actually quite simple, just add a 'your drop-down word' in-between the ()'s.


Last edited by Pecola1 (2011-04-24 10:58:49)
Offline
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!
Offline
scimonster wrote:
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!
I know its op not op, I just wasn't looking at the source right then. I also know its under private, it is also under all though, all has all of them.
Offline
Pecola1 wrote:
scimonster wrote:
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!I know its op not op, I just wasn't looking at the source right then. I also know its under private, it is also under all though, all has all of them.
Why not put it in the original place?
Offline
scimonster wrote:
Pecola1 wrote:
scimonster wrote:
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!I know its op not op, I just wasn't looking at the source right then. I also know its under private, it is also under all though, all has all of them.
Why not put it in the original place?
IDK. It is quicker to click --all-- than private.
Offline
Pecola1 wrote:
scimonster wrote:
Pecola1 wrote:
I know its op not op, I just wasn't looking at the source right then. I also know its under private, it is also under all though, all has all of them.Why not put it in the original place?
IDK. It is quicker to click --all-- than private.
Really?
Offline
Pecola1 wrote:
scimonster wrote:
Pecola1 wrote:
I know its op not op, I just wasn't looking at the source right then. I also know its under private, it is also under all though, all has all of them.
Why not put it in the original place?
IDK. It is quicker to hit --all-- than private.
Man, that sounds kinda wrong.
Offline
scimonster wrote:
Pecola1 wrote:
scimonster wrote:
Why not put it in the original place?
IDK. It is quicker to click --all-- than private.
Really?
--all-- is always on the very top, you do notice we are both on right?
Offline
scimonster wrote:
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!
You are like the only one that actually reads these. LOL its kinda sad.
Offline
scimonster wrote:
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!
Hey! Its under evaluation not private! LOL.
Offline
scimonster wrote:
Still a great tutorial!
I am starting Chap 4!
Offline
Pecola1 wrote:
scimonster wrote:
Pecola1 wrote:
IDK. It is quicker to click --all-- than private.Really?
--all-- is always on the very top, you do notice we are both on right?
Yeah. CommandBlockMorph is in the middle though. Why don't you just say both?
Offline
Pecola1 wrote:
scimonster wrote:
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!Hey! Its under evaluation not private! LOL.
Um, Scratch-Blocks -> CommandBlockMorph -> private -> uncoloredArgMorphFor:.
Offline
scimonster wrote:
Pecola1 wrote:
scimonster wrote:
A couple things:
It is "ops" not "opps"
It is in private, not --all--
...That's it.
Still a great tutorial!Hey! Its under evaluation not private! LOL.
Um, Scratch-Blocks -> CommandBlockMorph -> private -> uncoloredArgMorphFor:.
Look at the system browser, its Scratch-Blocks -> CommandBlockMorph -> evaluation -> uncoloredArgMorphFor:. Unless you have a different version. Or maybe I changed it on mine, lemme check on one I haven't edited. Hmm... your right, LOL I will have to talk to ssss about this, i was using the RKT System Browser, everything in command block morph is mixed up! Thank you for pointing that out.
Last edited by Pecola1 (2011-03-01 12:49:48)
Offline
Pecola1 wrote:
scimonster wrote:
Pecola1 wrote:
Hey! Its under evaluation not private! LOL.Um, Scratch-Blocks -> CommandBlockMorph -> private -> uncoloredArgMorphFor:.
Look at the system browser, its Scratch-Blocks -> CommandBlockMorph -> evaluation -> uncoloredArgMorphFor:. Unless you have a different version. Or maybe I changed it on mine, lemme check on one I haven't edited. Hmm... your right, LOL I will have to talk to ssss about this, i was using the RKT System Browser, everything in command block morph is mixed up! Thank you for pointing that out.
You're welcome.
Offline
ProgrammingFreak wrote:
Thanks!
U R WELCOME.
Offline
Pecola1 wrote:
Code:
reportSingle: t1 'infinity' = t1 ifTrue: [^ Float infinity]. 'nil' = t1 ifTrue: [^ nil]. 'pi' = t1 ifTrue: [^ Float pi]. 'phi' = t1 ifTrue: [^ '1.61803399']. 'e' = t1 ifTrue: [^ Float e]. 'newline' = t1 ifTrue: [^ String crlf]. 'tab' = t1 ifTrue: [^ ' ']
Is this a separate method? If so, can I put code in the code in between the '[ ]''s? Instead of reporting it? I'm making a block that is an upgrade of 'move () steps'. This one allows you to choose which direction you would like to step. I have the code for the direction, now i just gotta make the drop down so i can make it all one block.
Offline
ProgrammingFreak wrote:
Pecola1 wrote:
Code:
reportSingle: t1 'infinity' = t1 ifTrue: [^ Float infinity]. 'nil' = t1 ifTrue: [^ nil]. 'pi' = t1 ifTrue: [^ Float pi]. 'phi' = t1 ifTrue: [^ '1.61803399']. 'e' = t1 ifTrue: [^ Float e]. 'newline' = t1 ifTrue: [^ String crlf]. 'tab' = t1 ifTrue: [^ ' ']Is this a separate method? If so, can I put code in the code in between the '[ ]''s? Instead of reporting it? I'm making a block that is an upgrade of 'move () steps'. This one allows you to choose which direction you would like to step. I have the code for the direction, now i just gotta make the drop down so i can make it all one block.
![]()
Do you mean the 'move () steps in () direction' block from RKT? If so use %d for the direction insert.
Offline
ProgrammingFreak wrote:
Pecola1 wrote:
Code:
reportSingle: t1 'infinity' = t1 ifTrue: [^ Float infinity]. 'nil' = t1 ifTrue: [^ nil]. 'pi' = t1 ifTrue: [^ Float pi]. 'phi' = t1 ifTrue: [^ '1.61803399']. 'e' = t1 ifTrue: [^ Float e]. 'newline' = t1 ifTrue: [^ String crlf]. 'tab' = t1 ifTrue: [^ ' ']Is this a separate method? If so, can I put code in the code in between the '[ ]''s? Instead of reporting it? I'm making a block that is an upgrade of 'move () steps'. This one allows you to choose which direction you would like to step. I have the code for the direction, now i just gotta make the drop down so i can make it all one block.
![]()
reportSingle and singleNames are separate methods.
Offline
Pecola1 wrote:
ProgrammingFreak wrote:
Pecola1 wrote:
Code:
reportSingle: t1 'infinity' = t1 ifTrue: [^ Float infinity]. 'nil' = t1 ifTrue: [^ nil]. 'pi' = t1 ifTrue: [^ Float pi]. 'phi' = t1 ifTrue: [^ '1.61803399']. 'e' = t1 ifTrue: [^ Float e]. 'newline' = t1 ifTrue: [^ String crlf]. 'tab' = t1 ifTrue: [^ ' ']Is this a separate method? If so, can I put code in the code in between the '[ ]''s? Instead of reporting it? I'm making a block that is an upgrade of 'move () steps'. This one allows you to choose which direction you would like to step. I have the code for the direction, now i just gotta make the drop down so i can make it all one block.
![]()
Do you mean the 'move () steps in () direction' block from RKT? If so use %d for the direction insert.
Oh, you guys already made that?
Oh and answer my other question.
Last edited by ProgrammingFreak (2011-04-17 19:32:47)
Offline
ProgrammingFreak wrote:
Pecola1 wrote:
ProgrammingFreak wrote:
Is this a separate method? If so, can I put code in the code in between the '[ ]''s? Instead of reporting it? I'm making a block that is an upgrade of 'move () steps'. This one allows you to choose which direction you would like to step. I have the code for the direction, now i just gotta make the drop down so i can make it all one block.![]()
Do you mean the 'move () steps in () direction' block from RKT? If so use %d for the direction insert.
Oh, you guys already made that?
![]()
Oh and answer my other question.
Yes, the []'s are like the C of an if block, you can report or not report. I used to think that it would stop the block if you put a code inside of it. But then I noticed only if you put a report inside will it stop, it will stop whenever you make it report. Silly me.
Offline
Pecola1 wrote:
ProgrammingFreak wrote:
Pecola1 wrote:
Do you mean the 'move () steps in () direction' block from RKT? If so use %d for the direction insert.Oh, you guys already made that?
![]()
Oh and answer my other question.Yes, the []'s are like the C of an if block, you can report or not report. I used to think that it would stop the block if you put a code inside of it. But then I noticed only if you put a report inside will it stop, it will stop whenever you make it report. Silly me.
![]()
Also, can you make variables anywhere?
Offline
ProgrammingFreak wrote:
Pecola1 wrote:
ProgrammingFreak wrote:
Oh, you guys already made that?![]()
Oh and answer my other question.Yes, the []'s are like the C of an if block, you can report or not report. I used to think that it would stop the block if you put a code inside of it. But then I noticed only if you put a report inside will it stop, it will stop whenever you make it report. Silly me.
![]()
Also, can you make variables anywhere?
What do you mean make variables anywhere? You mean the watcher allowed off the stage? (yes) Or make a new variable for a certain sprite from another sprite? (yes again) Do you mean make it so the user can make their variable go to motion, control et cetera? (yeperoo) What do you mean?
Offline
Pecola1 wrote:
ProgrammingFreak wrote:
Pecola1 wrote:
Yes, the []'s are like the C of an if block, you can report or not report. I used to think that it would stop the block if you put a code inside of it. But then I noticed only if you put a report inside will it stop, it will stop whenever you make it report. Silly me.![]()
Also, can you make variables anywhere?
What do you mean make variables anywhere? You mean the watcher allowed off the stage? (yes) Or make a new variable for a certain sprite from another sprite? (yes again) Do you mean make it so the user can make their variable go to motion, control et cetera? (yeperoo) What do you mean?
Like making variables in between the '||' anywhere? Or is that just at the top?
Offline