Etoys Tips and Tricks: Difference between revisions
(added profiling info) |
(added non-obvious positioning trick) |
||
Line 77: | Line 77: | ||
and use the inspector's 'chase pointers' command to get some idea of |
and use the inspector's 'chase pointers' command to get some idea of |
||
why each one exists. |
why each one exists. |
||
===Positioning of players=== |
|||
You've been there right?: You have 34 objects in your etoys window and you want to position them evenly. So you measure the space you want to cover, do a quick calculation, open the viewer for every player and adjust the x and the y accordingly. Tedious, boring and mind-numbing. So much so that you stopped developing with Etoys altogether. If this is your story, then rejoice! Cause there is a better way!: |
|||
One can group different player objects by pressing shift and the left mouse button (forgot which color that is) while mousing around. This will create a rectangle which selects every player which it wholly contains (much like your favorite RTS). Letting go will keep the rectangle in place. |
|||
And now the fun begins. Cause by clicking the halo-menu-icon you'll be presented with a couple of align commands at the bottom of the option pane. You can for example align them horizontally, or at the top edge of your rectangle. |
|||
How's that for an easter egg!! |
|||
[[Category:Etoys]] |
[[Category:Etoys]] |
Revision as of 07:55, 17 March 2008
Just a few tips and tricks to overcome a few common hurdles your average Etoys beginner (that would be me) might run into.
Oneliners
when image hangs: alt-.
recover from hang on smalltalk level: world-leftclick > changes > recently logged changes. Select all the relevant changes and file them in.
Text input box hacks
the Etoys input box is a bit flaky and basic at the moment. One of the OLE Nepal guys is working on a general fix, but for now we can tweak it with a few hacks:
Textboxes change size, depending on whether there is text in there or not. We can fix this by opening an inspector on an instance and execute:
self beAllFont: (StrikeFont familyName: 'BitStreamVeraSans' size: 24)
Or whatever font you want it to be of course.
To let the box respond with a function on a carriage return, define an etoys script (or squeak function) with, say, name #myOwnFunction, open an inspector on the appropriate instance and execute:
self crAction:(MessageSend receiver: self player selector: #myOwnFunction)
To obtain keyboard focus on the textbox of your choice, you can use the following function:
obtainKeyboardFocus ActiveHand keyboardFocus: self costume renderedMorph. self costume renderedMorph editor selectAll
The last line perhaps doesn't give you what you want, cause it selects the whole text every time focus is lost and regained again, but you can always take it away of course.
Installing Monticello on your Etoys image
At the moment you hit upon a bug when you want to install Monticello in an Etoys image through Squeakmap.
There's a way around this though. As from http://ircbrowse.com/channel/squeak/20070927 :
First download MonticelloBackport.8.cs and Monticello-kph-434.st (or, if you want to install monticello as part of the Epaati image customization procedure, go to the monticello-hack-files dir in etoys-migration-files)
Load the MonticelloBackport.8.cs file into your image and then load the Monticello-kph-434.st file. While loading the latter you will hit upon an error. Push 'debug' and find MCWorkingCopy Initialize in the stack trace. Return 'nil' from it. Then open a workspace or something and execute 'MCWorkingCopy registerForNotifications'. This should provide you with a working Monticello. Upgrade Monticello if you feel like it.
There might be another way around this bug, which we have yet to try. There's a compatibility layer called 'level playing field' (levelPlayingField/LPF.st) which tries to smoothen out the differences between different image forks. Might work. Or we could fix the bug of course!!
Profiling in Smalltalk
From Luke Gorrie's mail on the Etoys list:
In this case what I did was find the guts to project loading (ProjectLoading>>openName:stream:fromDirectory:) and wrap most of the method body up like this:
TimeProfileBrowser onBlock: [ ... original code ... ].
and that popped up a window with excellent time profile information. An alternative way to do this, which doesn't interact so well with project loading specifically, is to use WorldMenu->debug->'Start message tally' and then drag the mouse to the top of the screen to finish profiling.
Now when I'm looking at memory usage I'm using:
SpaceTally new printSpaceAnalysis
and then running its output (STspace.txt) through e.g.:
awk '$5 > 1 { print }'
to see classes accounting for >= 1% of memory usage. Then individually I can do something like:
(Bitmap allInstances select: [:b | b size > 100000]) explore
and use the inspector's 'chase pointers' command to get some idea of why each one exists.
Positioning of players
You've been there right?: You have 34 objects in your etoys window and you want to position them evenly. So you measure the space you want to cover, do a quick calculation, open the viewer for every player and adjust the x and the y accordingly. Tedious, boring and mind-numbing. So much so that you stopped developing with Etoys altogether. If this is your story, then rejoice! Cause there is a better way!:
One can group different player objects by pressing shift and the left mouse button (forgot which color that is) while mousing around. This will create a rectangle which selects every player which it wholly contains (much like your favorite RTS). Letting go will keep the rectangle in place.
And now the fun begins. Cause by clicking the halo-menu-icon you'll be presented with a couple of align commands at the bottom of the option pane. You can for example align them horizontally, or at the top edge of your rectangle.
How's that for an easter egg!!