Problem with TextFieldMorph
Ned Konz
ned at bike-nomad.com
Mon Jul 21 20:19:43 UTC 2003
On Monday 21 July 2003 12:31 pm, Vincent Foley wrote:
> I recently started using Squeak, and I wrote my first small GUI
> application
> (http://darkhost.mine.nu:8080/~vince/Password%20Generator.st),
What created that text? It has some weird combination of CR and CRLF
line endings, as well as a stray ^L (formfeed) character or two...
Also, it's a bit odd to have methods with names beginning with capital
letters.
And your class variables shouldn't be initialized every time you make
a new PasswordGen.
You can stick the contents of PasswordGen>>init into PasswordGen
class>>initialize.
Then provide class-side accessors for the class variables.
Also, #alphaAction is not defined.
And you might consider making PasswordGenApp a subclass of Model (for
instance); although it's a subclass of SystemWindow, there's no
SystemWindow behavior there. So there's no need to be a subclass of
SystemWindow.
In fact, you're constructing a plain SystemWindow in drawApp and
opening that.
And it's bad form to open a window (or to open anything) in a Morph's
#initialize method.
Better to keep the window construction that's in drawApp (perhaps
renaming it something like #open), and just change the superclass.
And you probably want to say
window model: self
somewhere so you can provide window dimensions and colors.
If you use the callbacks provided by the Pluggable* classes, you don't
have to keep instance variables that point to the fields.
> but
> this application has a severe bug: when the contents of a
> TextFieldMorph is deleted, the user cannot input anything in the
> field anymore. Why is that?
Because it has a bug?
If you use a plain PluggableTextMorph you won't have this problem. Or
you could use a TextMorph and then use #acceptOnCR: and #crAction:.
You can say:
ptm := PluggableTextMorph on: self text: #getSomething accept:
#setSomething:.
ptm acceptOnCR: true.
> Is there some code to add, or should I use PluggableTextMorph (in
> which case, I would like to know how to remove scroll bars)
They don't have scroll bars by default; if you only have a single line
of text and the PTM is tall enough you won't have scroll bars.
Try this in a Workspace and see what I mean:
o _ Object new.
ptm _ PluggableTextMorph on: o text: #printString accept: nil.
ptm height: TextStyle defaultFont height + 6.
ptm acceptOnCR: true; openInHand.
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|