Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combobox doesn’t react on text input from textfile

    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);
    }
    }

  • #2
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder djpaul1963's Avatar
    Join Date
    Apr 2012
    Location
    Athens GR
    Posts
    75
    Thanks
    0
    Thanked 8 Times in 8 Posts
    You must trigger the combobox onselect event programatically to achieve that.

  • #4
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •