This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GuiComposer Combobox widget



Hello,

Once again I find myself thwarted by Guicomposer. This time I'm having trouble persuading the combobox widget to work bi-directionally.

I have a number of short ints in my target program into which I want to be able to allow the user to set specific values.

I thought the combo box would be the ideal tool for this. Now I can get it set up with the aid of a bit of background pre-processing javascript to convert the short int value to a suitable string. i.e to convert the numbers 1,2,3 into strings  "1phase", "2phase" & "3phase" and it displays these fine so it is doing something.

Interestingly I could not get the "Switch case" function to work in my javascript pre-processing code and had to resort to using  an  "if else" function instead. Might this be due to the short data type on the target? I couldn't think of anything else that would stop it working and checked the syntax several times with a javascript reference example. I could find no guidance regarding javascript's sensitivity to datatypes. I used a separate text widget on my test display the numeric data was being displayed fine..

Now, try as I might I can't get the combobox to work the other way round, i.e if I want to be able to select the 1phase, 2phase or 3phase drop downs in the box that I have designed into the widget it just sits there and won't update the bound variable.

I have tried various options firstly doing nothing nothing (hoping that the default value might be 1,2,3 for the design labels) then I have tried putting some post processing javascript to convert the "1phase", "2phase" etc strings into the numbers 1,2,3 and various other guesses. But as yet, no success and I have casted around looking for an example to no avail....

So if you can point me at a good example of bidirectional usage of this widget or perhaps suggest where I'm going wrong that would be helpful.

regards

Steve

 

 

  • Hi Steve,

    You can use the Select widget for your purpose. In the Widget tab, enter the Labels and the Values that you want, i.e nine,eight,seven,six for Labels, and 9,8.7,6 for Values. In the Binding tab, enter the target variable for the Selected Value.

    Regards,
    Patrick

  • Hello Patrick,

    That works fine and will serve my purposes nicely. Thankyou.

    However, I remain confused as to what the purpose of the combo box is if it is not there to allow the user to send preselected data to the bound variable?

    regards

    Steve

  • Hi Steve,

    The combo box is meant for binding labels to a target array of string type or numeric type, and binding the value to a numeric target type. When an item is selected in the combo, the numeric value on the target should reflect the index of the combo. However, bi-directional is not working for string type at the moment. 

    For example, these two arrays can be bound to the labels attribute and the selection can be bound to the value attribute of the combo widget.
    const char *labels[3] = {"1", "2", "3"};
    const int nums[3] = {1, 2, 3};
    int selection = 2;

    Regards,
    Patrick

  • Thanks, shame the bi-directional was not working:-)