Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 通过alt+鼠标单击在FLEX中启动MapMouseeEvent_Apache Flex_Flash Builder - Fatal编程技术网

Apache flex 通过alt+鼠标单击在FLEX中启动MapMouseeEvent

Apache flex 通过alt+鼠标单击在FLEX中启动MapMouseeEvent,apache-flex,flash-builder,Apache Flex,Flash Builder,我想通过键盘快捷方式和鼠标点击组合来启动MapMouseEvent。这是我的一部分,我不确定逻辑是否正确: private function MapClick(event:MapMouseEvent):void { if (event.altKey) altPressed = true; { Alert.show("Alt key has been pressed - click on screen"); // launc

我想通过键盘快捷方式和鼠标点击组合来启动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

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

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

山姆:谢谢你的回复。我已经下线了,回复有点晚,对此我很抱歉。是的,我应该更清楚地排除这里的else语句。好的,我会检查一下,看看我能不能让它运行。。。