Link to home
Start Free TrialLog in
Avatar of thebellman
thebellmanFlag for United States of America

asked on

Remove focus from ItemRenderer

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?

Thanks.




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(); "/>
			
		
	</s:Panel>

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

Avatar of zzynx
zzynx
Flag of Belgium image

I think that last onClick() version should work in combination with the information you can find @ http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_7.html
ASKER CERTIFIED SOLUTION
Avatar of aubweb
aubweb
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thebellman

ASKER

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

parentDocument.hbFlexHeightEdit.setFocus();

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.

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