...

View Full Version : Combobox doesnít react on text input from textfile



Student1989
05-30-2012, 11:01 AM
At this point Iíve got a combobox that gets its content from a SQLite database.
The user can select an item from the combobox or type the name of the item and then select it. When an item name is selected, the item is shown on the screen. Those functions work.

I made an open and a save function. The save function saves the name of the item in a text file. The open function opens the name of the item in the combobox. But then nothing happens. It doesnít matter if I hit Enter. It seems that the combobox doesnít recognize the text as input.

It is important to save and open the name of the item and not the item itself, because the item can be changed in the database. Then an old item would be shown and not the updated one.

I want the combobox to open the item when the item name is loaded in the combobox. What are the solutions for this problem?

This is the code that loads the name of the item in the combobox:

private function openComplete(e:Event):void
{
try
{
var data:ByteArray = fileRef.data;
combo.textInput.text = data.readUTFBytes(data.bytesAvailable);


}
catch(errObject:Error)
{
Alert.show("Foutmelding: " + errObject);
}
}

Student1989
06-07-2012, 09:21 AM
Iíll try to explain the problem more clearly.

I want the name that is loaded from the textfile into the combobox to be selected from the list.
Once an item is selected everything works just fine. But I don't want the user to select the item, when the name is loaded into the combobox. The user will expect that the item will be selected automatically. Is that possible?

The function I want is the opposite of combobox.selectedItem. Instead of having a selected item and getting the name, I have a name and I want to select the item.

The name is a correct name, because the name is saved from the combobox.

djpaul1963
06-07-2012, 03:57 PM
You must trigger the combobox onselect event programatically to achieve that.

Student1989
06-08-2012, 09:54 AM
I found the problem.
Iíve tried to loop through the array of names before. It got me thinking. It had to work, but it didnít.

for (i = 0; i < this.dataprovider.length ; i++){
if(this.dataprovider.getItemAt(i).name == name ){
combo.selectedIndex = i;
break;
}
}

I found out that when I looped throught the data, the method that opened the item wasn't used anymore. In the combobox I used change to call the method.
When I use caretChange instead of change, the method is used.

So when I open the file with the itemname, the itemname is loaded in the combobox and the item is opened on the screen.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum