I have a viewstack which implements a ‘wizard’ interface for doing new orders. On the last page of the wizard, there is a button, with a fake accelerator on it, by which, if they press ‘o’, they can start the process over again.
Below is my handler:
protected function _keyDownHandler(e:KeyboardEvent):void
{
if((e.charCode == 111)) {
// stop the 'o' from getting out
trace("Cancelable : " , e.cancelable);
this.removeEventListener(KeyboardEvent.KEY_DOWN, _keyDownHandler, true);
e.stopImmediatePropagation();
e.preventDefault();
model.orderNew();
}
}
The problem is that when the user gets back to page 1 of the wizard, the ‘o’ the user just typed is now entered into a datagrid filtering textbox (filter by last names starting with ‘o’), which is not what is desired.
As you can see, I’ve made some attempts at forbidding this interaction, but it appears to be not enough, even though the model.orderNew() bit contains all the code to swap the viewstack pages around, re-setting the focus to the txtSearchFilter, etc…I’m quite stymied!
It appears that e.cancelable == false, which is probably why I’m getting this behavior..but the documentation says that KEY_DOWN IS cancelable, so…I’m still lost.
How can I keep the keypress from propagating to the form ?
Thanks
Check out this thread:
http://forums.adobe.com/thread/434862
It appears that both the KEY_DOWN and KEY_UP events are not cancellable in the flash player.