Inserting text in text area at current cursor position from keyboard as well as from programmer made keyboard in flex4?

StackOverflow https://stackoverflow.com/questions/15847749

  •  01-04-2022
  •  | 
  •  

سؤال

I am trying to insert text at current cursor position.I am able to insert text at current cursor position by keyboard but not able to insert text by programmer made keyboard.

هل كانت مفيدة؟

المحلول

            var pos:int = taMain.selectionActivePosition;

            if (pos != -1)
            {
                taMain.text = taMain.text.substr(0, pos) + str + taMain.text.substr(pos, taMain.text.length - pos);
                taMain.selectRange(pos + str.length, pos + str.length);
            }
        }
    ]]>
</fx:Script>

نصائح أخرى

HI try with below code:-

protected function greekalpha_clickHandler(event:MouseEvent):void {     
                if(FlexGlobals.topLevelApplication.textTarget.visible) { 
                    FlexGlobals.topLevelApplication.textTarget.setFocus(); 
                    FlexGlobals.topLevelApplication.textTarget.insertText((event.target as Button).label); 
                } 
            }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top