0

Howto detect "reverse" focus change, i.e. shift+tab

asked 2009-01-27 17:35:40 +0800

cvarona gravatar image cvarona
554 1 6

Hi,

I'm preparing some forms for a certainly exigeant customer. Incredible though it may seem it's been the focus behaviour that has raisen most of his complaints so far; his requirements are

1) onOK on input boxes must take the focus to the following components
2) when blurring from a component placed before any listbox (listboxes are inherently unfocusable, but for those in mold "select") the focus must "get into" the listbox and be placed on the previously selected item, if any, or in the first one otherwise
3) when the "last" component in the form has been reached pressing tab must take the focus to the "first" one

In order to accomplish this I've had to write a complex form analysis, so that before deciding what component to set the focus on I can evaluate whether it's visible, visible by itself but actually hidden because of any of its ancestors being invisible, whether it's disabled, whether it's an empty non-selectable listbox (in which case it must be simply skipped), etc.

And well, all of this I can manage more or less. But I've realised that by modifying the default focus behaviour like this I've spoilt the "reverse" focus behaviour. My general scheme amounts to listen to 'onOK' and 'onBlur' and then analyse the form in order to determinate which the "next" component is. This is something I ought to do also for the "previous" component. The main difficulty lies in telling 'tab' from 'alt+tab'; apparently there is no way to specify 'tab' as ctrl key, or at least I've been unable to find it. I've tried to use csa in order to catch onkeydown or onkeypress in order to transform it into a onUser event via the comm object, but rather unsuccessfully (I've tried action="onkeydown: comm.onUser( this )" but my js console tells mi there is no such method in comm).

Any suggestion as to how to accomplish this would be much appreciated

César Varona

delete flag offensive retag edit

2 Replies

Sort by » oldest newest

answered 2009-01-28 23:20:21 +0800

judacoor gravatar image judacoor
280 1 3 8

Sorry if this sounds kinda dumb....

But what if you implement onCancel() to represent the 'reverse focus'? That way could instruct the end-user to press the ESC key when he want to go back inside a form.

judacoor

link publish delete flag offensive edit

answered 2009-01-29 08:31:34 +0800

cvarona gravatar image cvarona
554 1 6

Well, even if it was acceptable for my customer to have onCancel as reverse focus (which looks to me as strange as having onOK=next component) my listening to onBlur would still be unable to tell 'blur forwards' from 'blur backwards'; since the onBlur event takes place before the focus change has actually taken place I'm considering to evaluate whether the component owning the focus is 'before' or 'after' the component that actually triggered the change. I think any other solution would imply resorting to javascript.

But thanks for your suggestion all the same.

César Varona

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-01-27 17:35:40 +0800

Seen: 287 times

Last updated: Jan 29 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More