That is a verry small isue, but some times we really need a fast answer.
I try to use setFocus method for diffrent UIComponents, for most of them it’s ok, but for a button for example you can’t see focus border using only setFocus method, so the solutions is to use also drawFocus method.
drawFocus method is called by the FocusManager when the component receives focus. The component should draw or hide a graphic that indicates that the component has focus. (recording flex help)
Please see this small example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="246" height="76"> <mx:Script> <![CDATA[ import mx.core.UIComponent; public function setFocusTo(object:UIComponent):void { object.setFocus(); } public function drawFocusTo(object:UIComponent):void { object.setFocus(); object.drawFocus(true); } ]]> </mx:Script> <mx:Button x="10" y="10" width="226" label="my button" id="myButton" /> <mx:Button x="10" y="42" label="set focus" click="setFocusTo(myButton)"/> <mx:Button x="103" y="42" label="set and draw focus" click="drawFocusTo(myButton)"/> </mx:Application> |
Tags: ActionScript, Add new tag, focus, MXML
This post was written by Stelian Crisan
Views: 16797










[...] did you try this: FLEX{er}
I have an question.Suppose i apply drawFocus() on text control in flex.Now if i resize the control using matrix transformation, will the drawFocus also resize when i apply it again.If not so how can i do it?Thanks in advance.
Hi,
It’s suppose to work. The focus it’s set on the actual size of the component, not on initial size or position.
I have to setFocus to TextField but textfield is not UIComponent. So How ca can I set the focus to textField?
Thanks…