===== Data exchange with GUI controls =====

Each control has an associated 'Value' which could be assigned to it by the SetVarAssoc command. The controls handle this value according to their type and subtype. To set a button's subtype, use the [[guiscript:Button_SetFlags]] command.

**Normal button:** the associated variable will be set to the 'Value', other controls are unaffected.

**CheckBox:** the associated variable will be or-ed with the value, other controls may change accordingly to the new value.

**RadioButton:** the associated variable will be set to the 'Value', other controls are changed accordingly to the new value.

**Progressbar:** the progressbar will handle Value as a percentage (it can't alter the value).

**Slider:** the slider will handle Value as a scaling factor (not the actual position!), it will set the associated Variable to Position*Value.

**TextEdit:** cannot be associated with a variable. You have to use QueryText()

**TextArea:** cannot be associated with a variable, use the various TextArea commands.

**Label:** labels work like a normal button, the Value will be assigned to the associated variable when the label was 'pushed'.

**ScrollBar:** Value will be set based on the scrollbar's knob position. The scrollbar will be redrawn based on Value. If a textarea was associated to the ScrollBar (via the .chu) then the textarea will also be scrolled.

**WorldMapControl:** whether travel allowed or not (change the cursor)

**MapControl:** the mapcontrol will use the first bit of the associated value to display mapnotes.

**Examples:**

   Progress = 0
   GemRB.SetVar ("Progress", Progress)
   Bar = LoadScreen. GetControl (0)
   Bar.SetVarAssoc ("Progress", Progress)
Bar is a ProgressBar control, the engine will refresh the "Progress" Global Dictionary Variable as it progresses with the EnterGame command.

   THac0RollsB.SetFlags (IE_GUI_BUTTON_CHECKBOX, OP_OR)
   THac0RollsB.SetVarAssoc ("Rolls", 1)
The above commands (from the options screen) will change the "Rolls" variable according to the CheckBox' state.

   BppButtonB1 = GraphicsWindow.GetControl (5)
   BppButtonB2 = GraphicsWindow.GetControl (6)
   BppButtonB3 = GraphicsWindow.GetControl (7)
   BppButtonB1.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
   BppButtonB2.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
   BppButtonB3.SetFlags (IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
   BppButtonB1.SetVarAssoc ("BitsPerPixel", 16)
   BppButtonB2.SetVarAssoc ("BitsPerPixel", 24)
   BppButtonB3.SetVarAssoc ("BitsPerPixel", 32)
The above commands will set up the BPP selection RadioButton group.

**See also:** [[guiscript:SetVarAssoc]], [[guiscript:SetVar]], [[guiscript:GetVar]], [[guiscript:QueryText]], [[guiscript:Button_SetFlags]], [[guiscript:accessing_gui_controls]]

[[guiscript:index|Function index]]
