links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Tabbed text morphs
Last updated at 4:19 pm UTC on 14 January 2006
Question: Brian Tabone October 26, 2004 A nice feature to have for data entry forms is tabbing between entry fields. I did some cursory searching for tabbing support from text morph to text morph, but haven't found anything. My thoughts are to subclass the TextMorph class and add an overridden keyStroke method that would trap a tab key entry and lookup the next TextMorph in the display list and set the focus to that TextMorph. Before I go through the trouble and possibly duplicate someones efforts, I wanted to know if anyone might know of a way to do this. Perhaps I'm missing something in Morphic that supports this sort of thing.

Answer: Chris Muller I remember seeing some tabbing support built into Morphic. I'm working on a UI utility in Morphic and ended up wrapping a TextMorph with my own "EntryFieldMorph" objects that end up controlling the TextMorph for me. It was easy-enough with Morphic to implement EntryFieldMorph>>#handleKeystroke:
and check the incoming KeyboardEvent's keyCharacter for Character tab, as in..
handleKeystroke: aKeyboardEvent
	| keyPressed |
	aKeyboardEvent wasHandled ifTrue: [ ^self ].
	keyPressed _ aKeyboardEvent keyCharacter.
	keyPressed = (self preferred: #keyForFocusShift) ifTrue: [ =^self shiftFocus: aKeyboardEvent ].
	keyPressed = ...
I don't see any harm in case-logic for checking hot keys..
A one liner to shiftFocus:
	aKeyboardEvent hand newKeyboardFocus: self nextTabStopMorph