0

我想通过组合键盘快捷键和鼠标单击来启动 MapMouseEvent。这是我所拥有的一部分,我不确定逻辑是否正确:

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");
        }
  }

我在这个网站上看过类似的例子,但仍然没有找到任何解决方案。我希望知道 FLEX 的人可以帮助我通过一系列键盘快捷键基本启动一个功能。例如:Alt + 鼠标单击,或 Shift + 鼠标单击,或类似的东西。原因是简单的鼠标单击已经在屏幕上执行了其他操作。

谢谢 ...

RJ

4

1 回答 1

0

您提供的代码非常接近正确。

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.
        }
  }

我写这个的方式,如果用户按住 ctrl+alt 并点击,两个函数都会运行。如果您希望 alt 优先于 ctrl 或类似的,下面的代码将起作用。

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.
        }
  }
于 2012-04-11T18:45:07.057 回答