View Full Version : [AS3] DataGrid component and keyboard input
mbjerkness
03-10-2008, 11:54 PM
I have searched, but have not found the answer I am looking for, so here goes...I have a DataGrid component and my stage is registered to listen for KEY_DOWN events. Once I click inside the DataGrid, my stage does not have the chance to respond to key events anymore. Is there any way for the DataGrid to consume only the key press events it wants to repsond to, i.e. up/down/left/right etc...but still have my stage received the events the DataGrid does not need. Or, can I have my stage receive the events the DataGrid consumes as well? I have a paged application and use the Escape key to go back to the previous page, but one of the pages has a DataGrid and I no longer receive the events once it is focused.
Thanks in advance.
Mike
mbjerkness
03-11-2008, 01:13 PM
So, after reading a lot more about events in AS3 I am assuming the DataGrid component is listening for KEY_DOWN events and the calling stopPropogation(), so the events are not bubbling back up to the stage. Is there a way to turn this off? I know that I can listen on the capture phase but I would much rather have the DataGrid not stop this event from being propogated.
cfunk
07-14-2008, 09:32 PM
Just in case anyone else comes by here with the same problem, (or you have yet to solve this yourself), here's how I worked around this issue...
Once I click inside the DataGrid...
This is the key. There's an inherited property for a DataGrid called focusEnabled that once set to false, will no longer take focus when the DataGrid is clicked.
As explained by the AS 3 language reference:
focusEnabled : Boolean
Gets or sets a Boolean value that indicates whether the component can receive focus after the user clicks it.
This seems to have solved my problem, hopefully it will work for you/others as well.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.