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

Good suggestion Mark, I personally would prefer omitting the attribute if 
you want to set the focus of the element that is the event target. 

The only down side with  this approach is that you no longer know which 
control would get the focus when looking at the markup.You could also for 
example attache the setfocus handler to the body of your html document. 
Then the focus will be set to a control if it gets invalid (there are some 
problems here when multiple controls get invalid in the same RRR, but that 
is another issue). But I'm not sure that this is a problem, you can also 
look at it as a feature.

Regards, 


Nick Van den Bleeken  -  Research & Development Manager
Inventive Designers
Phone: +32 - 3 - 8210170
Fax: +32 - 3 - 8210171
Email: Nick_Van_den_Bleeken@inventivegroup.com

public-forms-request@w3.org wrote on 08/08/2008 01:58:23 PM:

> 
> 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
> 
> -- 
> Mark Birbeck, webBackplane
> 
> mark.birbeck@webBackplane.com
> 
> http://webBackplane.com/mark-birbeck
> 
> webBackplane is a trading name of Backplane Ltd. (company number
> 05972288, registered office: 2nd Floor, 69/85 Tabernacle Street,
> London, EC2A 4RR)
> 
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> --
> 
> 

Inventive Designers' Email Disclaimer:   http://www.inventivedesigners.com/email-disclaimer =
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--

Received on Friday, 8 August 2008 13:30:50 UTC