Okay, So I have the following block that I've created;
Blockspec:
('Right Click Menu %s %s %s' r rightButtonMenu2:opt2:opt3: 'opt1' 'opt2' 'opt3')
Method:
rightButtonMenu2: t1 opt2: t2 opt3: t3 | menu | menu _ CustomMenu new. menu add: t1 action: t1. menu add: t2 action: t2. menu add: t3 action: t3. ^ menu startUp: #test
My question is, how do I make the reporter report a blank string instead of 'nil' when the user clicks off the menu without selecting an option?
Offline
I haven't modded Scratch in a while, but something like this might work:
test isNil ifTrue: [^ ''] ifFalse: [^ test].
Replace "test" with the variable that contains the menu item that was clicked.
Offline
nathanprocks wrote:
I haven't modded Scratch in a while, but something like this might work:
Code:
test isNil ifTrue: [^ ''] ifFalse: [^ test].Replace "test" with the variable that contains the menu item that was clicked.
This might sound silly, but how do I set each menu option to define said variable?
Offline
nsmbodabor wrote:
^Bump
nXIII answered your question. Here's the code pieced together:
rightButtonMenu2: t1 opt2: t2 opt3: t3 | menu result | menu _ CustomMenu new. menu add: t1 action: t1. menu add: t2 action: t2. menu add: t3 action: t3. result _ menu startUp: #test. ^ result ifNil: [''] ifNotNil: [result]
Offline