我有一个(希望)快速的问题。我有一些步进盒。尽管这可能适用于任何交互式组件。当我点击其他任何地方(包含舞台)时,我希望所选框失去焦点。是否有捷径可寻?我似乎无法找到一种有效的方式使它失去焦点。Flex:失去组件焦点
2
A
回答
3
如果任何人在这里找到自己的方式寻求解决这个问题,这里就是答案:
private function onGlobalMouseUp(event : MouseEvent) : void {
var fm:FocusManager = new FocusManager(stage);
//Since Flash Player can set focus on subcomponents as well as on components themselves,
//findFocusManagerComponent is used to find the component that either has focus or contains the subcomponent
//that has focus. If, for example, a TextField contained within a TextArea component has focus, findFocusManagerComponent
//will return the TextArea component, and not the TextField. This being the case, we can definitely determine
//whether the target object of the MouseUp event is a component (or is part of a component). If the target
//object is NOT a component (nor contained within one), then we clear all component focus.
if(fm.findFocusManagerComponent(event.target as InteractiveObject) is UIComponent){
//target of MouseUp is either a UIComponent, or is contained within a UIComponent, so do nothing.
}else{
//target of MouseUp is neither a UIComponent, nor is it contained within a UIComponent, so set component focus to null.
fm.setFocus(null);
}
}
0
2
所以这里的解决方案,我想出来的,工作得非常好。我有一个名为add()
的功能,它已被分配到applicationComplete
。在该功能我包括:
this.skin.addEventListener(MouseEvent.MOUSE_UP, loseFocus);
的呼叫:
private function loseFocus(e : MouseEvent) : void
{
if (e.eventPhase == EventPhase.AT_TARGET)
{
this.focusManager.deactivate();
}
}
够简单了,而且做什么,我一直在寻找。 “阶段”过滤器是必要的,以防止其他组件注册点击。
重要提示:this.skin
需要成为事件目标。舞台不会在Flex应用程序中暴露于鼠标。
如果有人有更好的解决方案,请建议之一!
+0
你钉了:)谢谢! – mik 2012-02-09 22:00:28
相关问题
- 1. UITextField失去焦点事件
- 2. jQuery失去焦点事件
- 3. 层失去焦点
- 4. UIGestureRecognizer“失去焦点”?
- 5. TextBox失去焦点
- 6. java - 失去焦点
- 7. 窗口失去焦点
- 8. 画廊失去焦点
- 9. Android的webview失去焦点
- 10. Javascript代码失去焦点
- 11. 失去焦点的按钮
- 12. 没有失去焦点
- 13. 检测UITextField失去焦点
- 14. 的UISearchBar失去焦点
- 15. 失去焦点AutoCompleteTextView问题
- 16. 捕获EditText失去焦点
- 17. 从JTextField失去焦点
- 18. 失去焦点的页面
- 19. 强制失去焦点
- 20. RecyclerView物品失去焦点
- 21. 失去焦点问题
- 22. C#RDP ActiveX控件失去焦点
- 23. 用户控件失去键盘焦点
- 24. (Jquery/Javascript)事件句柄 - 失去焦点
- 25. 没有失去焦点事件jQuery的
- 26. 失去焦点事件后,LookUpEdit失去其价值
- 27. 黑莓浆果有焦点和失去焦点的事件吗?
- 28. 我如何检测一个Flex应用程序失去焦点
- 29. JSF自定义组件失去输入焦点在AJAX更新
- 30. Treeview物品在失去焦点时失去选择
它不会自动失去焦点,当您单击其他地方? – JeffryHouser 2010-08-24 01:38:04
不能我管理。如果我点击其他任何地方,一旦选择了一个组件,我只能选择另一个组件。我不能通过点击舞台来取消选择所有组件。 – grey 2010-08-24 01:41:32