If anyone has a solution that doesn't involve JavaScript in the html wrapper I'd love to hear it...
The problem is, Internet Explorer interprets control-key sequences (such as ctrl-r which reloads the browser window) regardless of whether your flex app captures the keystrokes or not, regardless of whether you setFocus() or not. The keystrokes still bubble to the browser. I have tested this both in Firefox and IE7, in Firefox the swf captures the control sequences without disturbing the browser, in IE7 the swf also captures the control sequences, but the browser also reacts to them which can be disastrous from the perspective of the application. This note from Adobe makes me think they have not come up with a simple fix for this yet: http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=events_054_21.html The only solution right now seems to be using JS in the wrapper to modify the browser behavior. Here are the related leads I've found so far: http://santrajan.blogspot.com/2007/03/cross-browser-keyboard-handler.html http://www.colettas.org/?p=69 I'd be happy to hear if anyone else has a better solution. --- In [email protected], "Michael Klishin" <[EMAIL PROTECTED]> wrote: > > From my experience setFocus helps in your case, just use it in > creationComplete handler of parent container (whatever it is) or component > root tag (which happens to be parent container as well) > > On 11/01/07, Lieven Cardoen <[EMAIL PROTECTED]> wrote: > > > > In Application is seems to work once with this.setFocus(), but then it > > doesn't work anymore. Is there a way to catch the keys at all time??? > > > > > > > > I think I'm missing something here. I have an application with some > > layoutContainers and in one of the containers a user can draw a groundPlan. > > > > When rubberBand is enabled, I want a user to be able to press CTRL and > > click with mouse so that rubberband disappears. > > > > > > > > This Container where the drawing happens is called GroundPlan.as (extends > > Container). > > > > > > > > In here I create sprites, ⦠and in here I should be able to catch > > KeyEvents⦠> > > > > > > > Thx, Lieven Cardoen, IndieGroup > > > > > > ------------------------------ > > > > *From:* [email protected] [mailto:[EMAIL PROTECTED] *On > > Behalf Of *Lieven Cardoen > > *Sent:* donderdag 11 januari 2007 12:32 > > *To:* [email protected] > > *Subject:* RE: [flexcoders] KeyBoardEvents > > > > > > > > Strange, because I click with mouse in the Container... > > > > > > ------------------------------ > > > > *From:* [email protected] [mailto:[EMAIL PROTECTED] *On > > Behalf Of *Jason Hawryluk > > *Sent:* donderdag 11 januari 2007 11:08 > > *To:* [email protected] > > *Subject:* RE: [flexcoders] KeyBoardEvents > > > > > > > > You need to make sure your container has the focus > > > > > > > > //from the parent of the container > > > > GroundPlan.setFocus(); > > > > > > > > > > > > //or try this after you have set the listeners. > > > > setFocus(); > > > > > > > > > > > > > > > > jason > > > > > > > > > > > > -----Message d'origine----- > > *De :* [email protected] [mailto:[EMAIL PROTECTED] > > la part de* Lieven Cardoen > > *Envoy� :* jeudi 11 janvier 2007 10:58 > > *� :* [email protected] > > *Objet :* [flexcoders] KeyBoardEvents > > > > Why are my KeyboardEvents not working? > > > > GroundPlan is a chilc of a Canvas⦠> > > > I also tried catching keyboard events in my Application.application but it > > doesn't work neither⦠> > > > I'm testing in Internet Explorer and my application has focus⦠thx. > > > > *public* *class* GroundPlan *extends* Container > > > > {... > > > > *public* *function* addEventListeners():*void*{ > > > > *this*.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); > > > > *this*.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); > > > > *this*.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDownHandler); > > > > *this*.addEventListener(KeyboardEvent.KEY_UP, myKeyUpHandler); > > > > } > > > > /** > > > > * > > > > */ > > > > *private* *function* myKeyDownHandler(event:KeyboardEvent):*void* { > > > > *trace*(*"myKeyDownHandler("* + event + *")"*); > > > > *if*(event.keyCode == Keyboard.CONTROL){ > > > > *this*.controlKeyDown = *true*; > > > > } > > > > } > > > > /** > > > > * > > > > */ > > > > *private* *function* myKeyUpHandler(event:KeyboardEvent):*void*{ > > > > *trace*(*"myKeyUpHandler("* + event + *")"*); > > > > *if*(event.keyCode == Keyboard.CONTROL){ > > > > *this*.controlKeyDown = *false*; > > > > } > > > > } > > > > *Lieven Cardoen > > **Application developer > > ** > > **indie**group** > > **interactive digital experience** > > **engelse wandeling 2 k18 > > b8500 kortrijk * > > > > > > > > > > -- > This was freedom. Losing all hope was freedom. > > Flex wiki (russian): flexwiki.novemberain.com > Red5 bug track: jira.red5.org > Red5 wiki: wiki.red5.org [use JIRA account] > > Chasing the beauty in programming: > www.ruby-lang.org | www.rubyonrails.org >

