PDA

View Full Version : comboBox and focus issue



jerryj
August 5th, 2008, 07:57 AM
Hi,

to get the focus back on the stage (and my KeyboardEvent) again,
on closing a comboBox I 've put


stage.focus = this in the listener for the close event of the comboBox.

Although it works, it also gives the error:

The supplied DisplayObject must be a child of the caller.

And I'm wondering why the listener gets called twice!?



cComboBox.addEventListener(Event.OPEN, openComboBoxListener);
cComboBox.addEventListener(Event.CLOSE,closeComboB oxListener);


stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);

function openComboBoxListener(e:Event):void {

trace("open");

}

function closeComboBoxListener(e:Event):void {

stage.focus= this;//errors: The supplied DisplayObject must be a child of the caller.
trace("close");//outputs twice "close"

}


function keyPressed(e:KeyboardEvent):void {

trace("pressed: "+e.keyCode);

} thanks,

Jerryj.