[Cuis-dev] moving focus with tab key

Mark Volkmann r.mark.volkmann at gmail.com
Tue Jan 28 17:54:15 PST 2025


I got tabbing between TextModelMorph instances to work!
It did require a small change to InnerTextMorph though.
I modified the following line in the processKeystrokeEvent method:

self handleInteraction: [ editor processKeystrokeEvent: evt ]

replacing it with this:

evt keyValue = 9 ifFalse: [
    self handleInteraction: [ editor processKeystrokeEvent: evt ]
].

This is demonstrated in the package I created at
https://github.com/mvolkmann/Cuis-Smalltalk-Greeter.
The attached screenshot shows the window that is opened when you open the
World menu, hover over Open, and click Greeter.
There are two TextModelMorphs.
Pressing the tab key while in the first moves focus to the second.
Pressing shift-tab while in the second moves focus back to the first.

The key is this block that is used in the keystrokeAction: of each
TextModelMorph.

handleTab := [ :evt |
    | isTab |

    isTab := evt keyValue = 9.
    isTab ifTrue: [
        evt buttons = 8 "shift key"
            ifTrue: [ evt hand keyboardFocusPrevious ]
            ifFalse: [ evt hand keyboardFocusNext ]
    ].
    isTab.
].

On Tue, Jan 28, 2025 at 3:06 PM Mark Volkmann <r.mark.volkmann at gmail.com>
wrote:

> 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.
>
> On Tue, Jan 28, 2025 at 3:01 PM Juan Vuletich <juan at cuis.st> wrote:
>
>> On 1/24/2025 9:17 PM, Mark Volkmann via Cuis-dev wrote:
>>
>> In Cuis Smalltalk using Morphic morphs, is there a relatively easy way to
>> enable using the tab key to move focus between text inputs like
>> TextModelMorph instances?
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>>
>> Not really, because tab is a valid character in TextModelMorph. See
>> #keyboardFocusPrevious and #keyboardFocusNext . Maybe tab could be disabled
>> as a character for specific morphs, so we can enable it for focus control.
>>
>> Cheers,
>>
>> --
>> Juan Vuletichcuis.stgithub.com/jvuletichresearchgate.net/profile/Juan-Vuletichindependent.academia.edu/JuanVuletichpatents.justia.com/inventor/juan-manuel-vuletichlinkedin.com/in/juan-vuletich-75611b3twitter.com/JuanVuletich
>>
>>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>


-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250128/ec8c80c4/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2025-01-28 at 7.48.55?PM.png
Type: image/png
Size: 13449 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250128/ec8c80c4/attachment-0001.png>


More information about the Cuis-dev mailing list