Tab-key navigation in dialogs/windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Tab-key navigation in dialogs/windows

marcel.taeumel
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


Reply | Threaded
Open this post in threaded view
|

Re: Tab-key navigation in dialogs/windows

Ron Teitelbaum
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 <[hidden email]> 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