TextField - 行为类似于 PowerPoint
我有一个使用 ActionScript 创建的动态文本字段(多行、自动换行和 autosize=true)。
运行 SWF 时,如果单击文本字段,您会看到一个箭头“移动”光标,然后您可以双击将其置于编辑模式以选择文本。我希望它像 PowerPoint 一样工作 - 如果您单击该框,您将始终看到一个闪烁的光标,能够选择/插入文本,并且您可以单击边框进行拖动,或单击角来调整大小。
我尝试添加 focusIn 事件 textField.stage.focus = this.textField
但这似乎没有做任何事情。当您单击文本字段时,我基本上希望它就像您双击(编辑模式)一样,而实际上不必双击。
奖励:我想选择所有文本,而不是第二次双击返回移动模式(或任何名称)。
TL;DR:我可以获取/设置动态文本字段的某些属性来查看我是否处于编辑或移动模式?
I have a Dynamic TextField created with ActionScript (multiline, wordwrap & autosize=true).
While running the SWF, if you click into the TextField you get an arrow "move" cursor, then you can double-click to put it into Edit mode to select text. I want it to work like PowerPoint - if you click into the box you'll always get a flashing cursor with the ability to select/insert text, and you can click on the borders to drag, or the corners to resize.
I tried adding the focusIn event textField.stage.focus = this.textField
but this didn't seem to do anything. When you click into the textField, I basically want it to act as though you followed with a double-click (Edit mode) without actually having to do the double-click.
Bonus: and instead of a 2nd double-click returning you to the Move mode (or whatever it's called) I want to select all text.
TL;DR: Is there some property of a Dynamic TextField that I can get/set to see if I'm in Edit or Move mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TextField
类不是为您想要的而设计的。您需要做的是创建
Sprite
的子类。我们将其称为SuperDuperTextField
。您必须将所有交互逻辑添加到SuperDuperTextField
。该SuperDuperTextField
又包含一个用于文本显示和编辑功能的TextField
。当不在编辑模式下时,您可能希望将
TextField
上的selectable
和SuperDuperTextField
上的mouseChildren
设置为false
使MouseEvent
正常工作。要切换到编辑模式,您需要设置焦点,可能还需要设置插入符位置。
希望有帮助。
the
TextField
class is not made for what you want.What you need to do is to create a subclass of
Sprite
. Let's call itSuperDuperTextField
. You'll have to add all the interactivity logic toSuperDuperTextField
. ThatSuperDuperTextField
in turn contains aTextField
for the text displaying and editing functionality.while not in editing mode, you may wanna set both
selectable
on theTextField
andmouseChildren
onSuperDuperTextField
tofalse
forMouseEvent
s to work correctly.To switch to edit mode, you'll need to set the focus and probably also the carret position.
hope that helps.