Morph question from a Squeak neophyte
Ned Konz
ned at bike-nomad.com
Thu Jul 17 17:37:23 UTC 2003
On Thursday 17 July 2003 09:56 am, Vincent Foley wrote:
> I made a little test in a workspace:
>
> [code]
> window _ SystemWindow new.
> text _ PluggableTextMorph new.
> text color: Color lightYellow.
> window addMorph: text.
> window openInWorld
> [/code]
>
> This is what I did. Is there anything I should've done that I
> didn't do?
Yes. You didn't plug it in.
The choice of what text field depends a lot on how and when you will
use its value.
If you want changes to the text to automatically notify some other
object, you can use the PluggableTextMorph.
If you want to ask the Morph what its contents are, you can use pretty
much any kind of TextMorph, though the TextFieldMorph is useful,
since it doesn't require an "accept" action.
The PluggableTextMorph is usually used like this:
ptm := PluggableTextMorph on: myObject text: #ptmText accept:
#ptmText:
Where #ptmText and #ptmText: are selectors that are understood by
myObject.
There is also #on:text:accept:readSelection:menu: if you want to be
able to set selections from myObject, and/or to provide a menu.
Now when someone accepts the text (which can be made to happen when
they hit Enter by saying "ptm acceptOnCR: true"), this is what
happens:
myObject ptmText: 'the new text'
And when you want to change the contents of the text field, you would
do this:
myObject changed: #ptmText
which would make the PTM get its changed text contents by doing
"myObject ptmText".
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|