-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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
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
Asked: 2009-01-27 17:35:40 +0800
Seen: 287 times
Last updated: Jan 29 '09