View Full Version : MouseEvent.ctrlKey
Anybody know how to use this?
clip.addEventListener(MouseEvent.ctrlKey, handler);
My thought was that it would check if the ctrlKey was down and if so, run the handler except the only thing I get is this error:
1119: Access of possibly undefined property ctrlKey through a reference with static type Class.
nvm..figured it out.
basically.
clip.addEventListener(MouseEvent.CLICK, handler);
function handler(evt:MouseEvent):void{
if(evt.ctrlKey)//if true
...do stuff...
}
}
dr_zeus
05-02-2008, 05:45 PM
ctrlKey is a property of a MouseEvent instance. It is to be used in the event handler.
clip.addEventListener(MouseEvent.CLICK, handler);
...
private function handler(event:MouseEvent):void
{
if(event.ctrlKey)
{
//do something
}
}
xwielder
05-02-2008, 05:46 PM
yep.
MouseEvent.ctrlKey:
Indicates whether the Control key is active (true) or inactive (false). That's it. Not whether it's being pressed or not.
Glad ya got it though.
thanks for looking .... and Dr_Zeus trumped me with his cleaner *looking* code... *evil glare*
does this work on the mac platform? anybody know?
the documentation says windows only, but I don't see a mac variant that doesn't require the AIR runtime.
dr_zeus
05-02-2008, 07:57 PM
The docs say it works fine:
On Windows, indicates whether the Ctrl key is active (true) or inactive (false). On Macintosh, indicates whether either the Ctrl key or the Command key is activated.
good call...my bad - was looking at the altKey descript. *head desk.
matteosistisette
07-25-2009, 06:46 PM
The docs say it works fine:
However I can't get it working on Mac, in a standalone projector.
I have this code, which does work in Windows:
fscommand("trapallkeys","true");
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyD ownListener);
public function keyDownListener(e:KeyboardEvent) {
switch (String.fromCharCode(e.charCode)) {
case "r":
if (!e.ctrlKey) return;
// do something
break;
case "t": // etcetera
}
}
The "trapallkeys" thing is because I'm trying to catch CTRL+R, which is already some shortcut for something (dunnow what), so if I don't use trapallkeys it won't be catched.
But with trapallkeys activated, in Windows the above code does work as expected.
However, in Macintosh it does not.
Anybody experienced any issue in using ctlKey in Macintosh? It is supposed to work both with the control and command key, but neither works to me.
By the way I am publishing the Mac projector from windows, but that is supposed not to matter...
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.