Question: Is there any reason a Spark Button would trap key events, in particular a "spacebar" key event?
Background: I've inherited and am maintaining a large legacy project done in Flex 4.6. I am seeing a weird behavior with a
Spark Button. Essentially, once the button has been clicked on (i.e. given focus) a keyEvent (spaceBar) will trigger the click event handler attached to the button.
The button is defined in
MXML (below) within an
MX:Module. The module has key event listeners attached to the stage but the event handlers for those do nothing with the button:
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, echoKeyDownHandler); this.stage.addEventListener(KeyboardEvent.KEY_UP, echoKeyUpHandler);
If I put a trace statement in the button's event handler to check the event type when this weird behavior occurs, the type is reported as a
click. I don't see anything in the docs for the Spark Button about capturing key events like this.
<s:Button id="toggleBtn" label="Editor" click="toggleBtn_clickHandler(event)" x="943" y="8"/>