使用 Squiggly 启用拼写检查后,删除键和箭头键停止工作

After enabling spell checking with Squiggly the delete key and arrow keys stop working

在 TextFlow 上启用 Squiggly 后,删除键和箭头键停止工作。如果我四处点击或切换应用程序并切换回来,它有时会再次开始工作。如果我根本不使用 Squiggly,删除键和箭头键将按预期工作。

这是我用来启用 Squiggly 的代码:

var locale:String = "en_US";
SpellUIForTLF.enableSpelling(myTextFlow, locale);

有没有人遇到过这个问题,有解决办法吗?

看起来像是 TLF 或 SpellUIForTLF class 的错误。在 SpellUIForTLF class 中有一个方法 "doSpellingJob" 被调用。在此调用之后,您需要重新选择文本流中的选择。

    // From customized SpellUIForTLF.as class
    public function doSpellingJob():void
    {
        if (_spellingEnabled == false) return;

        hh.clearSquiggles();
        for (var idx:int = 0; idx < mTextFlow.flowComposer.numControllers; idx++)
        {
            var testController:ContainerController = mTextFlow.flowComposer.getControllerAt(idx); 
            //if (getValidFirstWordIndexTLF(testController) != -1) 
                spellCheckRangeTLF(getValidFirstWordIndexTLF(testController), getValidLastWordIndexTLF(testController));
        }

        if (hasEventListener(Event.COMPLETE)) {
            dispatchEvent(new Event(Event.COMPLETE));
        }


        if (keepFocusOnTextFlow && !calledSetFocusOnce) {
            setFocusOnTextFlowContainer();
            calledSetFocusOnce = true;
        }
    }

    public function setFocusOnTextFlowContainer():void {
        //trace("Setting focus on textflow");
        var testController:ContainerController;

        if (mTextFlow.flowComposer) {
            if (mTextFlow.flowComposer.numControllers) {
                testController = mTextFlow.flowComposer.getControllerAt(0);
            }
        }

        FlexGlobals.topLevelApplication.stage.focus = null;

        if (testController) {
            FlexGlobals.topLevelApplication.stage.focus = testController.container;
        }

        if (mTextFlow.interactionManager) {
            //mTextFlow.flowComposer.updateAllControllers();
            mTextFlow.interactionManager.setFocus();
            var selectionState:SelectionState = mTextFlow.interactionManager.getSelectionState();
            //TextObject(currentObject).textFlow.interactionManager.clearSelection();
            mTextFlow.interactionManager.selectRange(selectionState.anchorPosition, selectionState.activePosition);
        }
    } 


    /**
     * Sets the focus on the first container controller on the first composition complete.
     * This is to fix a bug in some situations where the delete and arrow keys do not 
     * work after spell checking has been enabled before the text flow composition 
     * has completed. Usually there is also a delay with editing the first time the dictionary loads. 
     * */
    public static var keepFocusOnTextFlow:Boolean;
    public static var calledSetFocusOnce:Boolean;

    public function SpellUIForTLF(textModel:TextFlow, lang:String)
    {       

        ...
        calledSetFocusOnce = false;

        if (keepFocusOnTextFlow) {
            setFocusOnTextFlowContainer();
        }

        ...
    }