Help! Text input with focus?

Karl Ramberg karl.ramberg at chello.se
Tue Apr 3 05:51:27 UTC 2001


This was a big annoyance for me in the first months using Squeak.
I made a change set that partly fixed the problem, and that was posted to the list.
I think a preference for turning this behavior off wound be great
karl

Ned Konz wrote:
> 
> On Monday 02 April 2001 22:12, Russell Allen wrote:
> > Hi all,
> >
> > This should be a simple question, but I've got completely stuck on it.
> > My software goes through a question and answer session, with the user
> > having to enter some text into a box, then press Enter to continue.
> >
> > However, all of the methods I have tried require the mouse pointer to be
> > in the text input box in order for that box to have the focus.   At
> > first I didn't notice this since I am used to both Squeak and various
> > Un*x environments with this sort of focus, but it drove the students I
> > was testing the software on completely batty - they were always clicking
> > in the text field, then moving then mouse away, then typing into thin
> > air.
> >
> > How can I get a simple text entry box in Morphic that grabs and
> > maintains focus even when the mouse leaves?
> 
> HandMorph>>newKeyboardFocus: aMorphOrNil
> HandMorph>>releaseKeyboardFocus
> HandMorph>>releaseKeyboardFocus:
> HandMorph>>newMouseFocus: aMorphOrNil
> 
> If a Morph has mouse focus, it will keep getting mouse move, up, and down
> events until it releases the focus.
> 
> If it has keyboard focus, it will get every keyboard event until it releases
> the keyboard focus.
> 
> There are a couple of problems:
> 
> The regular PluggableText entry fields (like in Workspaces and
> FillInTheBlankMorphs) lose their editor (and hence keyboard focus) on
> mouseLeave. And they create their editor (and keyboard focus) on mouseEnter.
> 
> TextMorphs aren't quite so bad, because at least they don't lose their editor
> on mouseLeave. You'd have to move your mouse over something else that wants
> keyboard focus (like another TextMorph or a PluggableTextMorph) before you
> lost your keyboard focus. Just moving it over the desktop won't do it.
> 
> So I'd try to use TextMorphs first, or subclass the PluggableTextMorph to be
> less agressive about losing mouse focus. (see
> PluggableTextMorph>>mouseLeave:).
> 
> Probably the safest thing to do is to grab both mouse and keyboard focus
> until the user hits Enter or Escape, but it's kinda rude to be so modal.
> 
> Tab will (if things are set up right) move between text fields on a pasteup
> (playfield).
> 
> --
> Ned Konz
> currently: Stanwood, WA
> email:     ned at bike-nomad.com
> homepage:  http://bike-nomad.com





More information about the Squeak-dev mailing list