删除 Flash 滑块组件上的键盘控制
默认情况下,可以使用键盘操作 Flash 滑块组件。有没有办法禁用此行为,以便用户只能用鼠标拖动滑块组件?
by default the flash slider component can be manipulated with the keyboard. Is there a way to disable this behavior so that users can only drag the slider component with their mouse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
很简单,只需将“Slider”对象的“focusEnabled”公共属性设置为 false:
这将表明“Slider”对象在用户单击它后无法接收焦点,因此不允许键盘与其交互。
Simple, just set the 'focusEnabled' public property of the 'Slider' object to false:
This will indicate that the 'Slider' object can't recieve focus after the user clicks on it and therefore not allow the keyboard to interact with it.
正如@Taurayi 和@Grant 提到的,改变焦点很简单。
这是一种更肮脏的方法,可以做同样的事情:
尽管
slider.focusEnabled = false;
更简单。这是一种更肮脏的方法:
如果您想要一种冗长但不那么肮脏的方法,只需将 fl.controls.Slider 子类化并将其设置为库中 Slider 符号的类即可。在您的子类中,您将添加:
keyDownHandler 继承自 fl.core.UIComponent 并在 Slider.as 中继承,因为它处理键盘更新。
华泰
As @Taurayi and @Grant mentioned, changing focus would be the simples.
Here's a dirtier way of doing somewhat the same:
Although
slider.focusEnabled = false;
is much simpler.Here's an even dirtier way:
And if you want a lengthy, but less dirty way, simply subclass fl.controls.Slider and set that as the class for the Slider symbol in your library. In your subclass you would add:
keyDownHandler is inherited from fl.core.UIComponent and in Slider.as it handles the keyboard updates.
HTH
添加:
到 SliderEvent.CHANGE 处理程序
这会将焦点转移到舞台,从而禁用滑块上的键盘活动。
Add:
To the SliderEvent.CHANGE handler
This will shift focus to the stage, and therefore disable keyboard activity on the slider.