![]() |
|
||||||||||
|
|||||
|
создаю текстовое поле:
createTextField("txt", mc.getNextHighestDepth(), 5, 5, 300, 610);
txt.type = "input";
txt.multiline = true;
txt.wordWrap = true;
txt.border = true;
txt.html = true;
txt.htmlText = "<b>Some</b> text here";
какие есть идеи? спасибо. |
|
|||||
|
Регистрация: Mar 2001
Адрес: msk
Сообщений: 1,416
|
всё время помнить выделение и по потере фокуса ставить его на место =)
|
|
|||||
|
Цитата:
может есть принципиально другие идеи? |
|
|||||
|
Регистрация: Mar 2001
Адрес: msk
Сообщений: 1,416
|
по нажатию кнопки фокус слетит полюбас. для того чтобы вернуть его назад нужно знать где он был и ставить обработчик (либо по таймеру либо по ивенту).. По другому - нужен другой текстфилд =)
|
|
|||||
|
don't panic!
Регистрация: Aug 2001
Сообщений: 4,121
|
если напрямик - можно так.
this.createTextField("TF", 0, 0, 0, 0, 0);
TF.autoSize = true;
TF.text = "Jackdaws love my big sphinx of quartz...";
//
TF.onKillFocus = function()
{
this.enterframe.removeMovieClip();
};
TF.onSetFocus = function()
{
if (!this.enterframe) {
var clip = _root.createEmptyMovieClip.call(this, "enterframe", 0);
} else {
var clip = this.enterframe;
}
this.select = {};
clip.onEnterFrame = function()
{
var tp = this._parent;
if (Selection.getFocus() == String(tp)) {
tp.select.s = Selection.getBeginIndex();
tp.select.e = Selection.getEndIndex();
tp.select.c = Selection.getCaretIndex();
}
};
};
// на кнопке
btn.onPress = function()
{
trace(TF.select.s); // индекс начала выделения
trace(TF.select.e); // индекс окончания выделения
trace(TF.select.c); // индекс каретки
};
|
|
|||||
|
можно onMouseMove самого текстфилда использовать:
this.createTextField("tf", 0, 0, 0, 0, 0);
tf.autoSize = true;
tf.text = "Jackdaws love my big sphinx of quartz...";
tf.sel='';
Mouse.addListener(tf)
tf.onSetFocus = function(){
this.onMouseMove=function(){
this.s=Selection.getBeginIndex();
this.e=Selection.getEndIndex();
}
}
tf.onKillFocus=function(){
this.sel=this.text.substring(this.s,this.e);
delete this.onMouseMove;
}
btn.onPress = function(){
trace(tf.sel);
};
|
|
|||||
|
don't panic!
Регистрация: Aug 2001
Сообщений: 4,121
|
да, ты прав :))
|
|
|||||
this.createTextField("tf", 0, 0, 0, 0, 0);
tf.autoSize = true;
tf.text = "Jackdaws love my big sphinx of quartz...";
btn.onRollOver = function(){
if(Selection.getFocus() eq tf ){
s=Selection.getBeginIndex();
e=Selection.getEndIndex();
}else{s=e=0;}
}
btn.onRelease = function(){
sel=tf.text.substring(s,e);
trace(sel);
Selection.setFocus(tf);
Selection.setSelection(s,e);
}
Последний раз редактировалось artcraft; 23.08.2005 в 20:55. |
![]() |
![]() |
Часовой пояс GMT +4, время: 16:59. |
|
|
« Предыдущая тема | Следующая тема » |
|
|