So yeah. I want to know because I am creating a 'BUild/Make your own blocks' feature.
Offline
ProgrammingFreak wrote:
So yeah. I want to know because I am creating a 'BUild/Make your own blocks' feature.
You can alt-click it and select "browse morph class."
Offline
Baderous wrote:
Take a look at ScriptableScratchMorph>>variablesPage.
Ah...
addVariable
| t1 t2 t3 t4 |
(t1 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self beep].
t2 _ NewVariableDialog ask: 'Variable name?'.
t2 = #cancelled ifTrue: [^ self].
t3 _ t2 first asUTF8.
t4 _ t2 second
ifTrue: [self]
ifFalse: [t1 workPane].
(t4 variableNameInUse: t3)
ifTrue:
[self beep.
DialogBoxMorph warn: 'That variable name is already in use'.
^ self].
t4 addVariable: t3.
t1 viewerPane categoryChanged: 'variables'.
self addWatcherForNewVariable: t3 withScope: t4Thanks!
But where are they added?
Last edited by ProgrammingFreak (2011-05-28 09:13:44)
Offline
Baderous wrote:
They are added in the method I mentioned.
The One I just posted? It didn't add...
Oh. just a second..
Nope. Didn't work.
Last edited by ProgrammingFreak (2011-05-28 09:22:23)
Offline
This one:
variablesPage
| t1 t2 t3 t4 t5 t6 t7 t8 |
t1 _ ScratchBlockPaletteMorph new color: (Color
r: 0.8
g: 0.8
b: 1.0);
borderWidth: 0.
t2 _ ScratchFrameMorph buttonLabel: 'Make a variable' localized selector: #addGlobalVariable.
(self isKindOf: ScratchSpriteMorph)
ifTrue: [t2 actionSelector: #addVariable].
t3 _ ScratchFrameMorph buttonLabel: 'Delete a variable' localized selector: #deleteVariable.
t6 _ 13.
t1 addMorph: (t2 target: self;
position: t6 @ 7).
t7 _ t2 bottom + 3.
t4 _ self varNames size > 0.
(t5 _ self ownerThatIsA: ScratchStageMorph)
ifNotNil: [t5 varNames size > 0 ifTrue: [t4 _ true]].
t4
ifTrue:
[t1 addMorph: (t3 target: self;
position: t6 @ t7).
t7 _ t3 bottom + 10.
t7 _ self
addVariableReportersTo: t1
x: t6
y: t7.
t7 _ t7 + 12.
t7 _ self
addGenericVariableBlocksTo: t1
x: t6
y: t7].
self addGenericListBlocksTo: t1 y: t7.
t1 updateWatcherButtonsForFrame: (self ownerThatIsA: ScratchFrameMorph).
t8 _ t1 submorphs inject: 0 into: [:t9 :t10 | t9 max: t10 right].
t1 extent: t8 + 10 @ t7.
^ t1Offline