GetGadgetItemState()

Syntax

Result = GetGadgetItemState(#Gadget, Item)
Description
Returns the item state of the specified gadget.

Parameters

#Gadget The gadget to use.
Item The item to get the state. The first item in the gadget has index 0.

Return value

Returns the state of the gadget item or 0 if there is an error. See below for the meaning of this value depending on the gadget type.

Remarks

This is a universal function that works for almost all gadgets which handle several items:
- CalendarGadget(): returns #PB_Calendar_Bold when the specified date is displayed bold, #PB_Calendar_Normal otherwise. 'Item' must be a SpiderBasic date value.
- ListViewGadget(): returns 1 if the item is selected, 0 otherwise.
- ListIconGadget(): returns a combination of the following values:
  #PB_ListIcon_Selected : The item is selected.
  #PB_ListIcon_Checked  : The item has its checkbox checked (#PB_ListIcon_CheckBoxes flag).
- TreeGadget(): returns a combination of the following values:
  #PB_Tree_Selected : The item is selected, 0 otherwise.
  #PB_Tree_Expanded : The item is expanded (a tree branch opened).
  #PB_Tree_Collapsed: The item is collapsed (the tree branch closed).
  #PB_Tree_Checked  : The Checkbox of the item is checked (#PB_Tree_CheckBoxes flag).
Check for these states like this:
  If Result & #PB_Tree_Checked
    ; Item is checked
  EndIf

Example

Below an example with the ListIconGadget(), how you can check for a combination of several results:
  If GetGadgetItemState(#Listicon, n) & #PB_ListIcon_Checked
    ; Item n is checked (no matter if selected)
  EndIf

  If GetGadgetItemState(#Listicon, n) & #PB_ListIcon_Selected
    ; Item n is selected (no matter if checked)
  EndIf

  If GetGadgetItemState(#Listicon, n) = #PB_ListIcon_Checked | #PB_ListIcon_Selected
    ; Item n is checked AND selected
  EndIf

  If GetGadgetItemState(#Listicon, n) & #PB_ListIcon_Checked | #PB_ListIcon_Selected
    ; Item n is checked OR selected OR both
  EndIf

See Also

SetGadgetItemState(), GetGadgetState(), SetGadgetState()
<- GetGadgetItemData() - Gadget Index - GetGadgetItemText() ->