This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-05-28 09:06:20

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

What is the 'New Variable' button called?

So yeah. I want to know because I am creating a 'BUild/Make your own  blocks' feature.

Offline

 

#2 2011-05-28 09:07:52

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: What is the 'New Variable' button called?

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."


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#3 2011-05-28 09:10:54

Baderous
New Scratcher
Registered: 2011-04-14
Posts: 100+

Re: What is the 'New Variable' button called?

Take a look at ScriptableScratchMorph>>variablesPage.

Offline

 

#4 2011-05-28 09:12:34

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: What is the 'New Variable' button called?

Baderous wrote:

Take a look at ScriptableScratchMorph>>variablesPage.

Ah...

Code:

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: t4

Thanks!  big_smile

But where are they added?

Last edited by ProgrammingFreak (2011-05-28 09:13:44)

Offline

 

#5 2011-05-28 09:18:19

Baderous
New Scratcher
Registered: 2011-04-14
Posts: 100+

Re: What is the 'New Variable' button called?

They are added in the method I mentioned.

Offline

 

#6 2011-05-28 09:21:20

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: What is the 'New Variable' button called?

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

 

#7 2011-05-28 09:45:09

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: What is the 'New Variable' button called?

This one:

Code:

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.
    ^ t1

/* No comment */

Offline

 

Board footer