[squeak-dev] Tab-key navigation in dialogs/windows

Ron Teitelbaum ron at usmedrec.com
Mon Aug 3 13:00:19 UTC 2020


Hi All,

We created a class CUserInterface and subclassed all of our forms from
there and did the following.  Widgets have tabStop (should tab stop here)
and tabOrder, they respond to hasTabFocus:  and implement onTabFocus and
onTabExit, which basically add or remove highlights the field, sents the
keyboard focus, (and tells the screen reader for blind users to read the
field name).

CUserInterface >> onTab
| allElements selectedElement i |
allElements := SortedCollection sortBlock: [:a :b | a tabOrder < b
tabOrder].
self allElementsDo: [:a |
   (a tabStop and: [a tabOrder > -1]) ifTrue: [
      allElements add: a
   ].
].
i := 0.
selectedElement := allElements detect: [:a | i := i + 1. a hasTabFocus =
true] ifNone: [nil].
selectedElement ifNotNil: [:a | a hasTabFocus: false].
(allElements at: (i+1) ifAbsent: [allElements first]) hasTabFocus: true.

There is also a onShiftTab to go backwards.

onShiftTab
| allElements selectedElement i |
allElements := SortedCollection sortBlock: [:a :b | a tabOrder < b
tabOrder].
   self allElementsDo: [:a |
   (a tabStop and: [a tabOrder > -1]) ifTrue: [
      allElements add: a
   ].
].
i := 0.
selectedElement := allElements detect: [:a | i := i + 1. a hasTabFocus =
true] ifNone: [nil].
selectedElement ifNotNil: [:a | a hasTabFocus: false].
(allElements at: (i-1) ifAbsent: [allElements last]) hasTabFocus: true.

All the best,

Ron Teitelbaum

On Mon, Aug 3, 2020 at 4:30 AM Marcel Taeumel <marcel.taeumel at hpi.de> wrote:

> Hi all!
>
> > A related topic might be the absence of tab navigation in Squeak. In
> many GUI systems there is a key to move the focus to the next widget,
> mostly the tab key. There is no such thing in Squeak, is it?
>
> It's not working. But here are code fragments:
>
> Morph >> #tabAmongFields
> Morph >> #tabHitWithEvents:
>
> Also browse senders of both.
>
> If I would implement it, I would do it as an event filter but only for
> Pluggable*Morph classes. The tool builder can then install those filters
> after building the widgets. Note that there is #keyboardFocusDelegate,
> which configures calls to HandMorph >> #newKeyboardFocus:. There is also
> #hasKeyboardFocus:.
>
> Best,
> Marcel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200803/63a574ad/attachment-0001.html>


More information about the Squeak-dev mailing list