Subroutines > Detailed Descriptions > XTREE > XTREE Parameters > coldef > cformat

Editable checkbox

cformat switch:  T (standard) or T+ (extended)

An editable checkbox is represented in the data and answer arrays by a one-character column coded according to the following table:

Code

Description

0

Unchecked

1

Checked

2

Indeterminate

4

Unchecked, disabled

5

Checked, disabled

6

Indeterminate, disabled

.

A space blanks out the cell entirely

 

Extended 2-state checkboxes (T+) support the following additional mouse & keyboard commands:

• When the focus is on a checkbox cell, Ctrl+A sets (ticks) all the enabled checkboxes in the column.

• When the focus is on a checkbox cell, Ctrl+B resets (clears) all the enabled checkboxes in the column.

• When the focus is on a checkbox cell, Ctrl+Z reverses the action of the immediately preceding Ctrl+A, Ctrl+B, or Shift+Click.

• To set (tick) a range of checkboxes in the same column, click to set the first checkbox in the normal way, then Shift+Click on the last checkbox in the range. Since this technique only works to set checkboxes, you the checkboxes at either end of the range must be unset to start with (because the click operation toggles the setting).

The following special context menu commands (see PopupMenu) relate specifically to extended checkboxes:

• $CBSET acts like Ctrl+A (sets all checkboxes in the column over which the mouse was right-clicked to bring up the context menu).  If the menu is activated by right-clicking on any column other than an extended checkbox column, this option will not appear on the menu.

• $CBRST is like $CBSET, but acts like Ctrl+B (reset or clear all checkboxes)

• $CBUNDO acts like Ctrl+Z.  Like $CBSET and $CBRST, it will only appear in the menu if the menu is activated for an extended checkbox column.  In addition, if undo is not possible, the option will be grey.

• $CBSETDEP is like $CBSET, but applies only to the dependents of the current item.  If the item clicked has no dependents, the option will be grey.  If the tree is not multi-level (XTF_MLVL not set – see flags), the option will not appear at all.

• $CBRSTDEP is like $CBSETDEP, but resets rather than sets the dependent checkboxes.

Because the above context menu commands adjust to the runtime circumstances, they can be added to the common PopupMenu for a tree, without regard to whether the tree even contains extended checkboxes, rather than having to add them only to column-specific context menus.  The only reason why these items weren’t just automatically defined for extended checkbox columns is to allow you to define the wording.  For example, for a tree in which the items represented styles of products, grouped into categories, you might define the context menu items as follows:

Coldef = "0~0~x~H~PopupMenu=Order all styles,$CBSET;Cancel all,$CBRST;"; &

+ “Order all styles in category,$CBSETDEP;Cancel all in category;$CBRSTDEP; &

+ "Undo;$CBUNDO~~"

 

The context menu might then appear as:

 

Notes

• You must also specify the flag XTF_EDITABLE when using checkboxes.

• If the checkbox column supports cell colors (cformat code B) then the column data (in both the data and answer arrays) should be two characters wide (instead of one), with the first character reserved for the color code.

• Use cformat code t for non-editable checkbox, and code 3 for three-state checkboxes.