97. toggleCollapsed
Prev | Chapter 6. Commands written in the Java™ programming language | Next

## 97. toggleCollapsed

Parameter syntax:

    [ 'state'|'toggle'|'collapse'|'expand'|'collapseAll'|'expandAll'
      [ '+' 'toggle'|'collapse'|'expand'|'collapseAll'|'expandAll']? ]?

Changes the state of the nearest collapsible view.

The ``nearest collapsible view'' is searched like this:

- Search starts at explicitly selected node if any; otherwise at node containing caret.

- If this node is an element and has a collapsible view, search is completed: this view is the ``nearest collapsible view''.

- Otherwise search continues with the parent of the node.

If this collapsible view is not found, then this command cannot be executed.

If this collapsible view is found, then this command returns a string, "`expanded`" or "`collapsed`", which reflects the state of the collapsible view after applying the operations specified in its parameter.

The parameter of this command specifies up to two operations. The default operation is `toggle`. Supported operations are:

`state`

  Does nothing at all. Allows to obtain the current state, "`expanded`" or "`collapsed`", of the collapsible view.

`toggle`

  Collapses nearest collapsible view if it is expanded and expands nearest collapsible view if it is collapsed.

`collapse`

  Collapses nearest collapsible view if it is expanded; otherwise has no effect.

`expand`

  Expands nearest collapsible view if it is collapsed; otherwise has no effect.

`collapseAll`

  Collapses nearest collapsible view and then, recursively collapses all its collapsible descendant views.

`expandAll`

  Expands nearest collapsible view and then, recursively expands all its collapsible descendant views.

Recommended bindings (found in the add-on called "A sample customize.xxe" — download and install it using Options → Install Add-ons):

    <binding>
      <keyPressed code="ESCAPE" />
      <charTyped char="/" />
      <command name="toggleCollapsed" />
    </binding>

    <binding>
      <keyPressed code="ESCAPE" />
      <charTyped char="+" />
      <command name="toggleCollapsed" parameter="expandAll" />
    </binding>

    <binding>
      <keyPressed code="ESCAPE" />
      <charTyped char="-" />
      <command name="toggleCollapsed" parameter="collapseAll" />
    </binding>

    <binding>
      <keyPressed code="ESCAPE" />
      <charTyped char="1" />
      <command name="toggleCollapsed" parameter="collapseAll+expand" />
    </binding>

Prev | Up | Next
96. status | Home | 98. toggleTextStyle