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

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

问题描述

我定义了一个使用空格的键盘快捷键.按下快捷方式后,会发生两件事:我的应用程序中的一些随机导航以及来自键盘快捷方式的 eventHandler 中的代码.

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.

我发现这个表格带有浏览器键盘快捷键,显然有时会使用空格进行导航.那么有没有办法在 Flex 中用空格停止导航,因为吃空格键按钮似乎不起作用:

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

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

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