;

PDA

Click to See Complete Forum and Search --> : v7-AS3 Lost focus in RichText Editor


imdumb
04-29-2009, 04:36 PM
Hello everyone,
I am trying to capture the focusOut event on the RichText Editor when I click on another part of the stage or another button. My problem is when I click on the Bold button or any other button on the RichText Editor it returns an focusOut event.
I would only like to have this event fire when I click something else other than the RichText Editor.

Any suggestions.

function fout(e:FocusEvent):void{
trace('out');
}

texteditor1.addEventListener('focusOut', fout);

I could have created a enterFrame event but I did not want to have a function checking the stage.focus.

When adding a class to a movie is there a way to isolate the class so that it only returns the events that are added to the main movie?

blanius
04-29-2009, 07:35 PM
Look into some of the focus events, there should be a way to do this. You may have to on focus out to then check that the object that is the reciever object and only respond if it's NOT on of the RT buttons.

imdumb
04-29-2009, 07:57 PM
Reason:
Trying to create a simple popup editor. If the user selects something else on the stage I want the editor to disappear and text saved. If the editor is part of class that I create. I would have thought when I load the class in a variable and set any event to that variable then the event would act as a global to the entire class.

w.brants
04-30-2009, 02:29 AM
An easy solution might be to add a listener to the stage for the mouseDown event and perform a hitTest to see if it was clicked outside of the RTE.function mdown(e:MouseEvent):void {
if (!texteditor1.hitTestPoint(e.stageX, e.stageY)){
trace ('clicked outside');
}
}

stage.addEventListener('mouseDown', mdown);

If you want a popup, you can also consider using a DragContainer. Assuming you have a RTE on stage named texteditor1var dc:DragContainer = new DragContainer();
ScriptedSkin.applyTo(dc);
addChild(dc);

dc.showClose = true;
dc.header.label.text = 'Rich Text Editor';
dc.object = texteditor1;
dc.move(20,20);