Morphic Data Entry

Lex Spoon lex at cc.gatech.edu
Tue Jun 8 12:16:16 UTC 1999


Neal Nelson <neal_nelson at primus.com.au> wrote:
> I'm new to Morphic and I'm having a problem creating fairly standard 
> windows which basically consist of data entry forms. I've tried using 
> TextMorph for my entry fields but I can't seem to get them to work as
a 
> normal entry field would. If I create then with text in them, they
keep 
> that length but if I create them empty (as the user needs to populate
the 
> field), they have zero length and any text entered isn't ever
displayed 
> but the pointer moves down a line for each character.
> 
> If anyone could explain to me how I can generate entry fields in
Morphic, 
> I'd be more grateful. I'm stumped on my current project until I can
entry 
> forms working.
> 
> Thanks.

The best approach for now is probably to use the pluggable text, list,
and button morphs.  You can make a model class that sits behind these
and notices whenever someone accepts some new text or presses a button.

One funny thing: the text morph requires explicit accept commands, or
changes don't register.  To get around this, you can remember all
pluggable text morphs that have been opened for the current model, and
when the "OK" button gets pressed, go through all the text morphs and do
an accept:

		textEntryList do: [ :m | m hasUnacceptedEdits ifTrue:[ m accept ] ].

(the hasUnacceptedEdits bit just keeps the morphs from flashing if text
has already been accepted)

In the longer run, if someone were to write up a more complete text
entry framework, that would be fabulous.  Such a framework might provide
for distinguishing between invalid data items (eg, "a34" where an
integer is expected), and provide a way to refuse to proceede if the
data on the form are inconsistent (eg, date of marriage is earlier than
date of birth).  Plus, automatically closing the form when someone hits
"OK" would be nice!

But that's a big project, and everyone will most likely hate the first
version....


Lex





More information about the Squeak-dev mailing list