Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   как получить выделеный текст (http://www.flasher.ru/forum/showthread.php?t=67363)

ALTER 01.08.2005 11:48

как получить выделеный текст
 
Привет всем!

Есть текстовое поле, в которое вводится текст, затем часть текста выделяется мышъю и этой части нужно затать форматирование...

Как задается форматирование всему тексту я знаю...

А вот как задать только выделенной части?

Я думаю нужно поймать начало и конец выделенного текста - только как? :confused: :confused: :confused:

iNils 01.08.2005 11:51

Читай про:
Selection (объект)
Selection.addListener
Selection.getBeginIndex
Selection.getCaretIndex
Selection.getEndIndex
Selection.getFocus
Selection.onSetFocus
Selection.removeListener
Selection.setFocus
Selection.setSelection

Der Grossen 01.08.2005 14:23

Офигенный пример из хэлпа к Flash MX Pro 7.2

Код:

this.createTextField("output_txt", this.getNextHighestDepth(), 0, 0, 300, 200);
output_txt.multiline = true;
output_txt.wordWrap = true;
output_txt.border = true;
output_txt.type = "input";
output_txt.text = "Enter your text here";
var my_cm:ContextMenu = new ContextMenu();
my_cm.customItems.push(new ContextMenuItem("Uppercase...", doUppercase));
function doUppercase():Void {
  var startIndex:Number = Selection.getBeginIndex();
  var endIndex:Number = Selection.getEndIndex();
  var stringToUppercase:String = output_txt.text.substring(startIndex, endIndex);
  output_txt.replaceText(startIndex, endIndex, stringToUppercase.toUpperCase());
}
output_txt.menu = my_cm;



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

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