【问题标题】:Get Cursor Postion of TextInput before it was focused out在聚焦之前获取文本输入的光标位置
【发布时间】:2012-11-01 07:38:39
【问题描述】:

我有带有 TextInput 的 Titlewindow 窗口。当它弹出时,我会执行其他操作,例如从顶级应用程序上的 Menu 中选择 MenuItem。 选择菜单项后,我需要将文本添加到之前关注的 titlewindow 的 TextInput。现在我得到了这些以前关注的 TextInput。但是无法找到光标或光标位置在聚焦时指向的索引。在这个位置我需要插入文本。

 var window:Window = FlexGlobals.topLevelApplication.window;
 window.focusManager.activate();
 var textInput:TextInput = window.focusManager.getFocus() as TextInput;

【问题讨论】:

    标签: actionscript-3 apache-flex flex4 flex4.5


    【解决方案1】:

    您是否尝试过聆听以将注意力集中在输入字段上,然后记录插入符号的位置?

    textInput.addEventListener(FocusEvent.FOCUS_OUT, internal_onFocusOutHandler, false, 0, true);
    protected function internal_onFocusOutHandler(e:FocusEvent):void
    {
       trace(textInput.selectionBeginIndex()+","+textInput.selectionEndIndex());
    }
    

    还有一个例子here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      • 1970-01-01
      • 2011-09-19
      • 1970-01-01
      • 2019-04-20
      相关资源
      最近更新 更多