Combobox Object

Synopsis

Class Name: Combobox
Valid Parents: Bulletin, Dialog, Toolbar
Valid Children: Popup

Description

A Combobox is a drop-down list of choices, with a text field showing the current selection.

  • The size of the drop down list is controlled by XuNguiHeight. The default height is one item high.
  • It is not possible to edit the text field showing the current selection - it must always be one of the values in the drop down list.

Inherited Resources

New Resources

Name Type Default
XuNguiCallback string undef
XuNguiCallbackData string undef
  • XuNguiCallback specifies the name of the function to call whenever the user interacts with the Combobox
  • If XuNguiCallbackData is specified then the value is used as the second argument to the callback function.
  • For more details - see Callback Functions
Name Type Default
XuNguiListItems dataset undef
XuNguiSelection string undef
XuNguiMustMatch float(boolean) true
  • XuNguiListItems is the list of strings to be shown in the drop down list. It must be a dataset or a fixed array of strings e.g. "'Higher'//'Lower'//'No change'"
  • The list of strings is only updated when XuNguiListItems is changed. It is not enough to set it to a dataset and then modify the dataset. In fact once the XuNguiListItems has been set you can destroy the dataset without affecting the combobox.
  • The list will not be updated if you set XuNguiListItems to the same dataset - it assumes the dataset has not changed. You must either use a different name for the dataset or set XuNguiListItems to undef and then back to the dataset. See UpdateComboList() in example below.
  • XuNguiSelection can be used to set or retrieve the current selection. You can also use GuiGetString and GuiSetString. If you try to set the combobox to a value not in the list - it is left blank.
  • XuNguiMustMatch can be used to allow new choices to be entered in the text field of the combobox.

Callback Information

Reason Event
XuCR_NONE Combobox clicked on
XuCR_VALUE_CHANGED A new value has been selected

 

Example Code

function ComboCB(string o, string d, float r)
  printf("o = '%s', d = '%s', r = %d\n", o, d, r);
endfunction
 
function UpdateComboList(string OBJ, string choices)
  string currentValue; 

  currentValue = GuiGetString(OBJ);
  WORK.ChoiceList = choices;
  $(OBJ).XuNguiListItems = undef;
  $(OBJ).XuNguiListItems = "WORK.ChoiceList";
  GuiSetString(OBJ,currentValue, false);
endfunction

  create Dialog gsharp_1.mydialog
   ( XuNguiDialogType = "bulletinBoard"
   );
  create Combobox gsharp_1.mydialog.combo
   ( XuNguiPosition = (10,10),
     XuNguiHeight = 50,
     XuNguiListItems = "'Choice 1'//'Choice 2'//'Choice 3'",
     XuNguiSelection = "Choice 3",
     XuNguiCallback = "ComboCB"
   );
  GuiPopupDialog("gsharp_1.mydialog");

  #UpdateComboList("gsharp_1.mydialog.combo", "Choice "+(3:5));

Return to Gsharp Applications Reference Manual