Nick Middleweek wrote:
>
> I totally understand you're thinking but I don't think there's a built in
> way of doing this. When you fire off the Alert component it has no
> knowledge
> of where it was fired off from. I guess you could look into Extending
> Alert
> to create your own MyAlert Class and override the show function (if
> possible) to allow another parameter to be passed in so MyAlert.show can
> receive an IUIComponent that is to get focus.
>
> I've not looked into it but conceptually it should work but at some point
> you'd still need to set the focus, either in the alertHandler or perhaps
> inside the new MyAlert Class?
>
> Personally, I would create a global variable to store the temp reference
> to
> the object you want to refocus in the alertHandler().
Hi,
Thanks for the confirmation; I just wanted to make sure that no easy/clean
way of doing this exists before proceeding with my hack.
Anyways, extending the Alert class seems of little use since the `show'
method is a static method. Maybe a custom Alert class like the below would
do the trick:
public class CustomAlert
{
private static var _focusElement:IFocusManagerComponent;
private static function myHandler(event:CloseEvent):void
{
if(_focusElement) _focusElement.setFocus();
}
public static function show(e:IFocusManagerComponent,
text:String = "", title:String = "",
flags:uint = 0x4 /* Alert.OK */,
parent:Sprite = null,
closeHandler:Function=null,
iconClass:Class = null,
defaultButtonFlag:uint = 0x4 /* Alert.OK */):Alert
{
_focusElement = e;
return Alert.show(text, title, flags, parent,
(closeHandler != null ? closeHandler : myHandler),
iconClass, defaultButtonFlag);
}
}
Pretty decent for a quick hack IMO. Thanks again, have a nice day. :-)
--
View this message in context:
http://old.nabble.com/Setting-focus-after-confirming-Alert-tp26885230p26891738.html
Sent from the FlexCoders mailing list archive at Nabble.com.