Yes there will be situations where you see the event on both the capture and bubble phases.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Josh McDonald Sent: Tuesday, March 04, 2008 9:09 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Global keyboard capture? A whole bunch of useful info there, cheers :D If you're listening on both phases to event X, will your handler be called twice? -J On Wed, Mar 5, 2008 at 3:02 PM, Alex Harui <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: For the record, so there is no more guessing: 1) The Application or WindowedApplication is not the top-level window and does not parent popup and thus events from popups do not bubble through the application 2) SystemManager is the top-level window, and all events from all display objects bubble through the SM unless their propagation has been stopped 3) Capture phase listeners on the SystemManager should get all events for all child display objects 4) If no display object has focus, but the player does have focus, then the Stage dispatches keyboard events which will not be caught by a listener on SystemManager 5) Capture phase listeners on the Stage will not catch events dispatched from the Stage, only events dispatched by children of the Stage and thus if no display object has focus, there is no place to hook a capture-phase listener that will catch the keyboard events dispatched from the stage. This is why Rick's suggestion of both a capture and non-capture phase listener on stage is correct. ________________________________ From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Rick Winscot Sent: Tuesday, March 04, 2008 8:18 PM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: RE: [flexcoders] Global keyboard capture? A continuance on the topic... >From the Flex reference: "All keyboard and mouse activity that is not expressly trapped is seen by the SystemManager, making it a good place to monitor activity should you need to do so." ...and "The stage is the root of the display list for the window." So - in reality... your implementation may determine which is better to use. But I do have something for you that might help. If you are having problems with the capture/bubbling/target phases you probably need to add two listeners as... Stage.addEventListener( KeyboardEvent.KEY_DOWN, handleKeyDn, true ); Stage.addEventListener( KeyboardEvent.KEY_DOWN, handleKeyDn, false ); This will ensure that you are truly listening for events in all three phases. Sorry for the earlier post - I didn't read the chain thoroughly and thought you were trying to do something else (face turns red). Rick Winscot From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Sherif Abdou Sent: Tuesday, March 04, 2008 2:43 PM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: Re: [flexcoders] Global keyboard capture? For Flex, use systemManager instead of stage from what i was told and the capture. no idea on combo sorry ----- Original Message ---- From: thirtyfivemph <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Sent: Tuesday, March 4, 2008 1:32:58 PM Subject: [flexcoders] Global keyboard capture? I'm wanting to globally capture the keyboard in my Flex app. I want to be notified of every keyboard event that happens as long as the Flash Player has the focus... regardless of whether the event happens when a UIComponent has keyboard focus or not. Here's what I'm doing: stage.addEventListe ner(KeyboardEven t.KEY_DOWN, handleKeyboard, false, int.MAX_VALUE) ; stage.addEventListe ner(KeyboardEven t.KEY_UP, handleKeyboard, false, int.MAX_VALUE) ; stage.addEventListe ner(KeyboardEven t.KEY_DOWN, handleKeyboard, true, int.MAX_VALUE) ; stage.addEventListe ner(KeyboardEven t.KEY_UP, handleKeyboard, true, int.MAX_VALUE) ; Since the stage is at the top of the display list, and since I'm listening for events in both the capture and bubble phase, and since I have the highest possible event priority, should I see all keyboard events? The problem is that I'm not... I've got a situation in my app where I start seeing only keyDown events with no matching keyUp events. It happens after I click on a ComboBox drop-down in a popup, then the popup is closed. At that point, I only get keyDown events until I click on another UI component. Any ideas what could be happening here? In general, is there a way I can guarantee that I can direct *all* keyboard events to a given function? Thanks, Troy. ________________________________ Never miss a thing. Make Yahoo your homepage. <http://us.rd.yahoo.com/evt=51438/*http:/www.yahoo.com/r/hs> -- "Therefore, send not to know For whom the bell tolls, It tolls for thee." :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>