¿El cursor se mueve a la ubicación de inicio en la selección en el cuadro combinado de chispa?

I have a . I provide arraylist as its data provider. my question is why moves to the ing location in when I select any item using enter key. Also when I press space from keyboard, again moves to ing location. How can I fix this? Thanks

protected function onInputKeyDown(e:KeyboardEvent):void
    {
      if(e.keyCode == 13)
      {
        AddPath(cb.textInput.text);
        cb.dataProvider = recentList;        
      }     
    }

here recentList is a Bindable ArrayList. Every Time when I enter anything in ComboBox and press Enter, The cursor moves to the beginning in the Text Area of ComboBox. AddPath function simply adds the new data to the recentList.

preguntado el 27 de agosto de 12 a las 12:08

Can you show some code? I thought after selection the cursor moved to the end of the list. -

1 Respuestas

When you set cb.dataProvider = recentList; you are essentially assigning a new pointer which overrides the previous list and resets the cursor.

You should be able to create a variable containing the selected item and manually set the ComboBox to that item on click/enter after you carry out the cb.dataProvider = recentList;

protected function onInputKeyDown(e:KeyboardEvent):void
{
    if(e.keyCode == 13)
    {
        var selectedItem:String = cb.selectedItem
        AddPath(cb.textInput.text);
        cb.dataProvider = recentList;   
        cb.selectedItem(selectedItem); 
    }     
}

Apologies if the code isn't perfect, but the theory should be right.

Respondido 28 ago 12, 09:08

I tried this. but it did not work. when I change the Selection using the Arrow keys and then Press backspace. Cursor moves to the beginning. - Sarfraz Ahmed

I also add 'cb.textInput.selectRange(cb.textInput.text.length, cb.textInput.text.length);' after giving recentList as dataprovider to the combobox. it shows the cursor on right, but as soon as I press backspace, cursor moves to the beginning. - Sarfraz Ahmed

the keycode is set to 13 - try putting the var selectedItem:String = cb.selectedItem before the if statement and the cb.selectedItem(selectedItem); after the if statement - keiran russell

This does not work. when we even click on combobox, dropdown list open and if we click on any item, that item get selected but cursor moves to the beginning. this is something that is in new spark combobox. - Sarfraz Ahmed

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.