Is callLater() a hack?

View: New views
2 Messages — Rating Filter:   Alert me  

Is callLater() a hack?

by Richard Rodseth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm wondering if I'm excessively purist about not wishing to use
callLater().

The specific case I have now is that I wish to set focus to the first field
of a re-usable form when a new item is created, and select all the text in
the field. Since I am using Mate, I have an injected listener in the view,
which gets invoked when a new item is created. Even though the text input
already has its text contents set by the time this listener is called, the
text doesn't highlight unless I wrap the setFocus call in callLater(). Any
ideas why that might happen?

Thanks.

RE: Is callLater() a hack?

by Alex Harui :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Life would be better if you didn't need callLater, but sometimes you do.  I wouldn't make it a staple of my code base though.

When you click on something, the FocusManager tries to give it focus so if you try to set focus somewhere else, it may be overridden by the FocusManager.
________________________________
From: flexcoders@... [flexcoders@...] On Behalf Of Richard Rodseth [rrodseth@...]
Sent: Tuesday, November 03, 2009 11:38 AM
To: flexcoders@...
Subject: [flexcoders] Is callLater() a hack?



I'm wondering if I'm excessively purist about not wishing to use callLater().

The specific case I have now is that I wish to set focus to the first field of a re-usable form when a new item is created, and select all the text in the field. Since I am using Mate, I have an injected listener in the view, which gets invoked when a new item is created. Even though the text input already has its text contents set by the time this listener is called, the text doesn't highlight unless I wrap the setFocus call in callLater(). Any ideas why that might happen?

Thanks.