I would like to launch a MapMouseEvent via a combination of keyboard short cuts and a mouse click. This is a portion of what I have, and I am not sure if the logic is correct:
private function MapClick(event:MapMouseEvent):void
{
if (event.altKey) altPressed = true;
{
Alert.show("Alt key has been pressed - click on screen");
// launch the function here
}
else
{
Alert.show(" Must click Alt key first, then click on map");
}
}
I have looked at similar examples on this site but still have not reach any solution. I am hoping that someone who knows FLEX can help me to basically launch a function via a series of Keyboard shortcut. For example: Alt + mouse click, or Shift + mouseclick, or something along those lines. The reason is that a simple mouse click already does something else on the screen.
Thanks ...
RJ
The code you've provided is very close to correct.
private function MapClick(event:MapMouseEvent):void
{
if (event.altKey);
{
//This means alt is held, AND a click occurred.
//run function for alt-click here
}
if (event.ctrlKey);
{
//This means ctrl is held, alt was *not* held, AND a click occurred.
//run function for ctrl-click here
}
if (!event.ctrlKey && !event.altKey)
{
//this means that a click occurred, without the user holding alt or ctrl
//run function for normal click here.
}
}
The way I wrote this, if a user holds ctrl+alt and clicks, BOTH functions run. If you'd rather have alt have priority over ctrl, or similar, the below code will work.
private function MapClick(event:MapMouseEvent):void
{
if (event.altKey);
{
//This means alt is held, AND a click occurred.
//run function for alt-click here
}
else if (event.ctrlKey);
{
//This means ctrl is held, AND a click occurred.
//run function for ctrl-click here
}
else
{
//this means that a click occurred, without the user holding alt or ctrl
//run function for normal click here.
}
}