I used to have no end of problems with textfield selection while developing the SMX components. The selection object behaves differently when text is selected by clicking on it to when text is selected by using the tab key or the setFocus method of the Selection object
 
i found the following seems to iron out differences in behaviour (bear in mind these are methods extended onto the Textfield class using prototype):
 
function onSetFocus(oldFocus) {
  _global.pressFlag = true;
  parent.selected = true;
  if(oldFocus != this) {
   parent.setFocusHandler(oldFocus);
   //do later to correct Selection errors...
   parent.doLater(this, "setFocusHandler", oldFocus);
  }
 }

  
 function setFocusHandler(oldFocus) {
  parent.setFocusHandler(oldFocus);
  var sEnd = Selection.getEndIndex ();
  var sBegin = Selection.getBeginIndex();
  Selection.setSelection(0, 0);
  Selection.setSelection(sBegin, sEnd);
 }
 
where doLater is a global method similar to the one found in mx components that executes a given function on a given object one frame later.
 
bold text is the important stuff
 

Rob
 
 
On 2/8/06, gilles Bertrand <[EMAIL PROTECTED]> wrote:
Hi list,

i'm workin on a small textEditor and working with comboboxes seem to
break all apart

when i shoot the change event of a combobox i renew the focus on the
text and then it break's up
her ie the code of my method

public function renewFocus():Void
{

       Selection.setFocus(texteCible);
       if(selectionExiste)
       {
               Selection.setSelection(startIndex,endIndex);
       }
       else
       {
               Selection.setSelection(carretIndex,carretIndex);
       }

}

everything works with a component button but not with combobox

Any help would be appreciated

Bertrand gilles

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org



--
~~~~~~~~~~~~~~~~~~~~~~~~
Rob Bateman - Flash Product Manager
BBC News Interactive

Tel: 0208 6248692
Mob: 07714 329073

[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to