Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   Позиция курсора в текстовом поле (http://www.flasher.ru/forum/showthread.php?t=208938)

stas0 22.09.2014 01:44

Позиция курсора в текстовом поле
 
Есть текстовое поле с текстом. Как определить точную позицию клика(символьную позицию)?
Код AS3:

public function InputText(){
        Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
        testTextField = new TextField();
        testTextField.width = 250;
        testTextField.height = 100;
        testTextField.border = true;
        testTextField.type = TextFieldType.INPUT;
        testTextField.x = 150;
        testTextField.y = -100;
        testTextField.defaultTextFormat = new TextFormat("Tahoma", 30);
        addChild(testTextField);
        NumbField.addEventListener(TextEvent.TOUCH_BEGIN, clickInTextField);
}
private function clickInTextField(e:TextEvent):void{
        testTextField.text = e.target.caretIndex;
        CursorPosIn = e.target.caretIndex;
 
        trace(e.target.caretIndex);
}

Оно то работает, но показывает предыдущую позицию(Например: текущая 5, показывает предыдущую 2).
Как исправить такое поведение?

Nooob 22.09.2014 04:36

есть TouchEvent.TOUCH_END, ещё есть MouseEvent.CLICK и selectionBeginIndex, selectionEndIndex, а ещё есть getCharIndexAtPoint или getCharBoundaries


Часовой пояс GMT +4, время: 07:30.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.