W3C home > Mailing lists > Public > public-forms@w3.org > August 2008

Re: Allow xf:setfocus with no @control to set the focus to the event target

From: Ulrich Nicolas Lissť <unl@dreamlab.net>
Date: Tue, 12 Aug 2008 20:49:41 +0200
Message-ID: <48A1DB45.3070004@dreamlab.net>
To: Mark Birbeck <mark.birbeck@webbackplane.com>
CC: public-forms <public-forms@w3.org>

Mark,

+1 from me. Makes it easy to set focus within repeats without needing to
understand id magic.

Regards,
Uli.

Mark Birbeck wrote:
> Hello all,
> 
> I was just looking something up in the spec, and noticed that if
> @control is omitted from the use of xf:setfocus then nothing happens.
> 
> It occurred to me that omitting @control and defaulting to the event
> target might actually be a useful pattern.
> 
> This example is a little contrived, because I've only just thought of
> the whole thing, but bear with me....
> 
> Ordinarily, setting focus on a control when it is invalid could be
> done like this:
> 
>   <xf:input id="me" ref="x">
>     <xf:label>X:</xf:label>
>     <xf:setfocus control="me" ev:event="xforms-invalid" />
>   </xf:input>
> 
> But that requires naming the control with an @id, and then ensuring
> that the @control value and the control name are in sync. An easier
> and more maintainable way would be:
> 
>   <xf:input ref="x">
>     <xf:label>X:</xf:label>
>     <xf:setfocus ev:event="xforms-invalid" />
>   </xf:input>
> 
> If people don't like simply omitting @control, an alternative would be:
> 
>   <xf:input ref="x">
>     <xf:label>X:</xf:label>
>     <xf:setfocus control="" ev:event="xforms-invalid" />
>   </xf:input>
> 
> Regards,
> 
> Mark
> 

-- 
Ulrich Nicolas Lissť
Received on Tuesday, 12 August 2008 18:50:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 October 2013 22:06:48 UTC