Adding items to Tools flap

Scott Wallace scott.wallace at squeakland.org
Fri Nov 9 09:31:24 UTC 2001


Steve,

There is a direct way you can add any morph to a parts-bin-like flap 
such as the standard Tools, Supplies, or Widgets flaps:

Just pick up the morph you want (e.g. with the black halo handle), 
drag it over the tab of the flap, and drop it onto the flap, at the 
position where you want it.  That's all!  This works with *any* 
morph.  No need to undertake any more strenuous exercise.  And the 
icon will be correct.

If the morph in question happens to be a System Window (as in the RB 
example), you first will need to set the "systemWindowEmbedOK" 
preference to true, so that when you try to drop the window into the 
flap, the flap will be willing to accept the drop.  After you've done 
the drop, you'll probably want to set the preference back to false, 
because it can be very annoying and disconcerting to have windows 
suddenly get swallowed up by other morphs.

Once you've dropped your RB into the Tools flap, the only missing 
thing will be a suitable balloon-help message, but this can be easily 
added.  I leave this as an exercise to the reader (but with this 
hint: look for the "edit balloon help" item found in the debug halo 
menu.)

Hope this helps,

   -- Scott

PS: I just tried to do exactly what I suggest above to get a RB into 
my Tools flap, and it worked immediately and without a hitch.


PPS: Alternatively you could, if you prefer, make a *code* change to 
modify the default contents that any particular system-predefined 
flap will have at launch.  Modify the big literal in the method that 
defines the contents of the flap, making any additions, deletions, or 
changes that you please.  The literal consists of a quadruple, the 
four elements being: Receiver, Selector, Label to show, Balloon Help.

In your particular case, you would patch in something like the 
following line into the literal in #quadsDefiningToolsFlap:

(RefactoringBrowser prototypicalToolWindow 'Refactoring Browser' 'A 
tool that shines your shoes')

What this would mean is: "when this item is requested, obtain a new 
morph by sending #prototypicalToolWindow to RefactoringBrowser, and 
then place that new morph in the Hand.  In the Tools flap, give the 
label 'Refactoring Browser' to the icon, and when balloon help is 
requested for the item, put up the message "A tool that shines your 
shoes'."


PPPS: The reason you got that MNU error message was that in the 
PartsBin protocol, when the designated selector is sent to the 
designated receiver to obtain a new instance, that instance *must* be 
a morph.  The expression "RefactoringBrowser openBrowser" returns not 
a morph but rather an instance of RefactoringBrowser, which is of 
CodeHolder lineage and certainly not a morph.  On the other hand, 
#prototypicalToolWindow *does* return a morph, indeed precisely the 
one you need.

Modulo that glitch, you *could* succeed by the approach you tried 
(e.g. by asserting that the selector #prototypicalToolWindow, rather 
than #openBrowser, be sent to RefactoringBrowser.)  However, that 
still will have the wrong label and the wrong icon, besides being so 
strenuous.


At 5:07 PM -0700 11/8/01, Steve Gilbert wrote:
>I'm attempting to add the Refactoring Browser to my Tools flap.
>The necessary expression that I need is:
>    RefactoringBrowser openBrowser
>
>Using prototype(Morphic) thinking I believe that I should be able to:
>
>1. Select an existing morph in the Tools.
>2. Duplicate that morph.
>3. Modify the correct stuff to invoke my desired expression.
>4. Drop into Tools area.
>5. Use globally like all other items inside the flap.
>
>I'm willing to forego a pretty icon as long as I can get an Refactor
>label on the bottom of it.
>
>Progress:
>1> Selected the existing Browser Icon.
>2> Duplicated it.
>3> Brought up the halo for the new Browser Morph(duplicate one) and
>selected the debug bubble, and chose Inspect Morph.
>4> Now I have an inspector on an Iconic Button.
>5> Changed target attribute to RefactoringBrowser.
>6> Changed arguments to #(#openBrowser).
>7> Leaving icon on the desktop if I mousedown a new Refactoring Browser
>comes up. (Partial Success!)
>
>However, I get a MNU on setProperty:toValue: invoked in
>    RefactoringBrowser class(Object)>>launchPartVia:
>
>I still haven't dealt with getting the new Browser Iconic Button tucked
>into the Tools flap, and I'd like to change the text as well.
>Any clues?   Is there a better way to do this?
>
>Steve Gilbert





More information about the Squeak-dev mailing list