如何取消 Halo/Spark TextInput 和 TextArea 组件中的编辑
我正在使用 Flex 4、ActionScript 3。
在 AdvancedDataGrid 组件中,当您在单元格中处于编辑模式时,您可以按 Escape 键取消编辑(即返回到单元格中的先前值)。
我原以为 Halo 和 Spark TextInput 和 TextArea 组件在编辑模式下会出现相同的行为,但惊讶地发现事实并非如此。
我查看了所有四个组件的属性,看看这是否是我需要配置的东西,但找不到任何东西。
这是需要编码的东西吗?
I am using Flex 4, ActionScript 3.
In the AdvancedDataGrid component, when you are in Edit mode in a cell, you can hit the Escape key to cancel editing (i.e. return to the previous value in the cell).
I had expected the same behaviour while in Edit mode in both the Halo and Spark TextInput and TextArea components, and was surprised to find out that this is not the case.
I looked at the attributes of all four components to see if this is something that I need to configure, but couldn't find anything.
Is this something that needs to be coded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是必须编码的东西。这是我将采取的方法:
UndoTextInput
。originalText
。focusIn
事件上添加事件侦听器。在focusIn
事件处理程序中,将当前文本值存储在originalText
变量中。focusOut
事件上添加一个事件。在focusOut
事件中,将originalText
的值设置回空字符串。keyDown
事件上添加事件侦听器。在事件侦听器中,检查是否按下了 Escape (Keyboard.ESCAPE
) 键。如果是,请将文本重置回originalText
中存储的内容。我希望这有帮助!
更新:
下面是一个关于如何使用 Actionscript 类执行此操作的快速示例。请随意根据需要进行修改。
Yes, this is something that will have to be coded. Here's the approach I would take:
UndoTextInput
.originalText
.focusIn
event. In thefocusIn
event handler, store the current text value in theoriginalText
variable.focusOut
event. In thefocusOut
event, set the value oforiginalText
back to an empty String.keyDown
event. In the event listener, check to see if the Escape (Keyboard.ESCAPE
) key was pressed. If it was, reset the text back to what was stored inoriginalText
.I hope this helps!
UPDATE:
Here's a quick example on how to do this using an Actionscript class. Feel free to modify as needed.