Remove focus from ItemRenderer

Posted on 2011-10-26
Last Modified: 2012-06-27
I'm having a heck of a time getting an itemRenderer on a Tree object to either fire the ItemEditEnd event of remove focus from the editor.

I need to give users 2 buttons on an itemrenderer that I'm using to edit Tree values.  I have an OK and a Cancel button.

The Cancel button is easy.

I'd rather have the default itemEditEnd Event handle the behavior and updates.  The question is how can I trigger that event via the 'OK" button.

Any ideas?


Here is my Edit component - nothing special:
<s:Panel x="10" y="10" width="250" height="131" id='EditPanel' title="Enter a new label">
			<s:Label id="labelDisplay" x="25" y="10"/>
			<s:TextInput id="picklistEditText" x="25" y="39" width="150" text=' ' />
			<s:Button x="1" y="67" label="OK" click='onClick()'/>
		<s:Button x="178" y="67" label="Cancel" click="parentDocument.mytreeEdit.destroyItemEditor(); "/>

Open in new window

I was trying to remove the focus from the editor:

private function onClick():void {
				stage.focus = null;

That doesn't seem to work.

Open in new window

I also tried to dispatch a manual keyboard stroke:

private function onClick(value:Object):void {
				var list:Tree = Tree(owner);
				list.callLater(dispatchEvent, [new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, Keyboard.ENTER, Keyboard.ENTER)]);	

That doesn't seem to work..

Open in new window

Question by:thebellman
    LVL 37

    Expert Comment

    I think that last onClick() version should work in combination with the information you can find @
    LVL 37

    Expert Comment

    LVL 1

    Accepted Solution


    Have you tried with : this.stage.focus = null; ?

    Otherwise as another workaround you can set the focus to another object doing : myOkButton.setFocus();

    Let me know if it helps.



    Author Comment

    The solution was to simply set focus on something else in the parent application -


    The button:

    <s:Button x="1" y="67" label="OK" click='cbSelected=picklistEditText.text;parentDocument.hbFlexHeightEdit.setFocus();'/>

    Where hbFlexHeightEdit is the HBox that holds the Tree that is being edited.

    LVL 37

    Expert Comment

    >> The solution was to simply set focus on something else in the parent application
    Then, don't you think aubweb deserve the/some points?

    Author Closing Comment

    Thanks - simple and it worked!

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
    Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video discusses moving either the default database or any database to a new volume.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now