AIR应用程序,在表单中设置光标位置
我有一个带有登录表单的 AIR 应用程序。 我想要做的是将光标设置在第一个文本输入框中。 我只设法将焦点设置在框上,而不是光标上。
有谁知道我该如何做到这一点?
I have an AIR application with a login form. What I want to do is set the cursor in the first textinput box. I only manage to set the focus on the box, but not the cursor.
Does anyone have an idea for how I can do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要将文本光标移动到文本字段,您只需设置阶段的焦点属性 到该字段。
stage.focus = myTextField;
要将光标移动到该 TextField 内的特定索引,请使用 setSelection():
To move the text cursor to a TextField you simply set the stage's focus property to that field.
stage.focus = myTextField;
To move the cursor to a specific index within that TextField, use setSelection():
据我所知,没有办法在actionscript(flash)中控制鼠标,mouseX / mouseY 属性是只读的。
不过,您可以创建一个“假鼠标”,您可以在 AIR 应用程序中移动它,但我怀疑这就是您想要做的事情,例如:
http://www.senoptic.com/demo/VirtualMouse/VirtualMouse.html
From what i know there is no way to control the mouse in actionscript (flash), the mouseX / mouseY property is read-only.
However you could create a "fake mouse" that you can move around in the AIR application but I doubt thats something you want to do, example:
http://www.senocular.com/demo/VirtualMouse/VirtualMouse.html
我可以建议在将焦点设置为文本输入之前设置活动本机窗口。
像这样的事情:
I can advise to set active a native window before set focus on text input.
Something like this:
您需要等待 Flex 容器注册到显示列表中,以便访问舞台。
从你的creationComplete处理程序中调用init:
You need to wait for the flex container to be registered with the display list so you access the stage.
Put a call to init from you creationComplete handler: