[Cuis-dev] moving focus with tab key
Mark Volkmann
r.mark.volkmann at gmail.com
Thu Jan 30 14:15:09 PST 2025
I found a better way to handle the tab key for moving focus between text
inputs.
Rather than modify InnerTextMorph or TextModelMorph, I did the following:
- Created a subclass of InnerTextMorph named InnerTextNoTabMorph.
This overrides the processKeystrokeEvent: method to be the same as in
InnerTextMorph except it does not process tab key events.
I also added an onChange: method that takes a block that it evaluates
every time it processes a key event.
- Created a subclass of TextModelMorph named TextInputMorph.
This has an initialize method that sets up event handling to handle tab
key presses and move focus appropriately.
It implements the innerMorphClass method to indicate that it wants to use
InnerTextNoTabMorph instead of InnerTextMorph.
It implements the onChange: method to forward a block onto the same
method in InnerTextNoMorph.
With these classes in place, my Greeter class uses TextInputMorph in place
of TextModelMorph
and voila tabbing between text inputs works great!
You can find all this code at
https://github.com/mvolkmann/Cuis-Smalltalk-Greeter.
On Wed, Jan 29, 2025 at 9:32 AM Hilaire Fernandes via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:
> That would be neat. But a Tab option in TextModelMorph may prove to be
> more useful for Widget as in Cuis-Smalltalk-UI.
> Le 28/01/2025 à 22:06, Mark Volkmann via Cuis-dev a écrit :
>
> Thanks Juan! I'll see if maybe I can create a subclass of TextModelMorph
> that has that behavior. Perhaps each instance of the subclass can hold a
> reference to another morph that should take focus when the tab key is
> pressed. Maybe I can create a set of morphs that have that ability such as
> checkboxes, radio buttons, and so on. That would enable creating user
> interfaces that are completely keyboard-driven as is common in web
> interfaces.
>
> -- http://mamot.fr/@drgeo
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
--
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250130/a02a4611/attachment.htm>
More information about the Cuis-dev
mailing list