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
        
        indiegroup
        interactive digital experience
        engelse wandeling 2 k18 
        b8500 kortrijk 

 

Reply via email to