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 PureBasic date value.
- ExplorerListGadget(): returns a combination of the following values
  #PB_Explorer_File      : The item is a file.
  #PB_Explorer_Directory : The item is a Directory (or drive).
  #PB_Explorer_Selected  : The item is currently selected.
- 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).
  #PB_ListIcon_Inbetween: The item's checkbox is in the "in between" state (#PB_ListIcon_ThreeState 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).
  #PB_Tree_Inbetween: The Checkbox of the item is in the "in between" state (#PB_Tree_ThreeState 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:
  ; ... here a code snippet from a WaitWindowEvent() - event loop:
  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()

Supported OS

All

<- GetGadgetItemData() - Gadget Index - GetGadgetItemText() ->