如何使用Space in Flex禁用默认的浏览器导航 [英] How to disable default browser navigation with Space in Flex

查看:269
本文介绍了如何使用Space in Flex禁用默认的浏览器导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义了一个使用空格的键盘快捷键。按快捷键后,有两件事情发生:在我的应用程序中的一些随机导航,也从键盘快捷方式我的eventHandler中的代码。

我发现这个表格与浏览器键盘快捷键和显然空间有时用于导航。那么是否有一种方法可以在Flex中停止空间导航,因为吃空格键似乎不起作用:

  FlexGlobals.topLevelApplication.addEventListener(KeyboardEvent.KEY_DOWN,
ignoreSpaceNavigation);

private static function ignoreSpaceNavigation(event:KeyboardEvent):
event.preventDefault();
event.stopImmediatePropagation();
}

那么任何想法如何停止导航? (我真的想为该键盘快捷方式使用空间!)

解决方案

尝试在舞台上设置事件监听器,并使用capture

  stage.addEventListener(KeyboardEvent.KEY_DOWN,ignoreSpaceNavigation,true); 


I have defined a keyboard shortcut that uses space. After I have pressed the shortcut two things happen: some random navigation in my app and also the code in my eventHandler from the keyboard shortcut.

I found THIS table with browser keyboard shortcuts and obviously space sometimes is used for navigation. So is there a way to stop the navigation with space in Flex, because eating the spacebar button doesn't seem to work:

  FlexGlobals.topLevelApplication.addEventListener(KeyboardEvent.KEY_DOWN,
                                                     ignoreSpaceNavigation);

  private static function ignoreSpaceNavigation(event:KeyboardEvent):
     event.preventDefault();
     event.stopImmediatePropagation();
  }

So any ideas how to stop the navigation? (I really want to use space for that keyboard shortcut!)

解决方案

Try to set event listener on a stage and use capture

stage.addEventListener(KeyboardEvent.KEY_DOWN, ignoreSpaceNavigation, true);

这篇关于如何使用Space in Flex禁用默认的浏览器导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆