<selectionmanager>
Manages selection among a series of objects.

JavaScript: lz.selectionmanager
extends <node> » lz.Eventable »

Selection managers manage selection among a series of objects. They enable standard control and shift click modifiers to aid range selection. Selection managers provide methods to manipulate, add to and clear the selection. For example:

<canvas>
   
      <dataset name="fruits">
        <fruit>Oranges</fruit>
        <fruit>Apples</fruit>
        <fruit>Bananas</fruit>
        <fruit>Grapes</fruit>
        <fruit>Kiwis</fruit>
        <fruit>Papayas</fruit>
        <fruit>Watermelon</fruit>
        <fruit>Strawberries</fruit>
        <fruit>Cherries</fruit>
      </dataset>
   
      <simplelayout/>
   
      <text>Select a series of items below. The control and shift-click modifiers
      help select ranges.</text>
   
      <view name="fruitlist">
        <selectionmanager name="selector" toggle="true"/>
        <simplelayout/>
   
        <view name="listitem" datapath="fruits:/fruit" onclick="parent.selector.select(this);">
          <text name="txt" datapath="text()"/>
   
          <method name="setSelected" args="amselected">
            if (amselected) {
              var txtColor = 0xFFFFFF;
              var bgcolor = 0x999999;
            } else {
              var txtColor = 0x000000;
              var bgcolor = 0xFFFFFF;
            }
            this.setAttribute('bgcolor', bgcolor);
            this.txt.setAttribute('fgcolor', txtColor);
          </method>
        </view>
   
        <method name="deleteSelected"><![CDATA[
          var csel = this.selector.getSelection();
          this.selector.clearSelection();
          for (var i = csel.length - 1; i >= 0; i = i - 1) {
            csel[i].destroy();
          }
        ]]></method>
      </view>
      <button onclick="fruitlist.deleteSelected();">Delete selection</button>
    </canvas>

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
sel string String setSelected read/write
  The name of the method to call on an object when an object's selectedness changes. The method is called with a single Boolean argument. The default value for this field is setSelected. (This feature is not available for <dataselectionmanager>.)
toggle boolean Boolean   read/write
   

Methods

clearSelection()
selectionmanager.clearSelection();
Unselects any selected objects.

getSelection()
selectionmanager.getSelection();
Returns an array representing the current selection.

isMultiSelect()
selectionmanager.isMultiSelect(o);
Determines whether the additional selection should be multi-selected or should replace the existing selection
Parameter Name Type Description
o   LzView The newly selected view

isRangeSelect()
selectionmanager.isRangeSelect(o);
Determines whether the additional selection should be range-selected or should replace the existing selection
Parameter Name Type Description
o   LzView The newly selected view

isSelected()
selectionmanager.isSelected(o);
Tests for selectedness of input.
Parameter Name Type Description
o   LzView The view to test for selectedness.

select()
selectionmanager.select(o);
Called with a new view to be selected.
Parameter Name Type Description
o   LzView The new view to make selected

unselect()
selectionmanager.unselect(o);
Unselects the given view.
Parameter Name Type Description
o   LzView The view to make unselected

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy