Wednesday, June 11, 2014

Re: setting value in current field based on button press

Thanks.  Your idea works perfectly.  That said, it made me notice two things ( which might indicate bad design decisions - I don't know yet ).  These comments are only for future reference, in case someone else comes along asking the same question.  They are things to beware of.
  1. The blur handler gets fired whenever we leave the field for any reason, which sort of makes sense.  So if I am doing this on the desktop and go to another window, it triggers the blur event.  Like I said, this makes sense, now that I think about it, but for some reason when I first read your advice, I did not see the "or" in "focus handler or a blur handler", so I was using both.  Definitely not right based on re-reading your comments below and my tests.  Like I said, obvious now, just missed it at first.
  2. If no field clicked on or has focus, and my button needs to fill in some arbitrary field, then I need to add logic to choose such a field, like maybe asking the user what field to fill in.  Because it is very very possible that no field will be selected when the button is pressed ( like when the page first loads ).  This is the part that might suggest an overall design flaw on my part.


On Wednesday, June 11, 2014 1:21:27 PM UTC-4, Jens wrote:
When you click a button then the input field will lost it's focus before the button click will be executed. That means you want to put the value into the input box that has been focused right before clicking the button. To get that information you can use a focus handler or a blur handler (= focus lost) to remember which input has been focused by the user.

-- J.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment