RasterTreeEvent

Object passed to a tree event handler containing information about the event in progress. The object has the following properties:
event       The associated DOM event object.
type        Indicates the type of event.
tree        The tree control that issued the event.
item        The tree item that was clicked.
dragValue   The value being dragged/dropped over the control.
position    Indicates where dragged value is about
            to be dropped.
Not all object properties apply to all event types. When a property is not relevant to a given event type, its value is set to null (Tip: do an alert() on the event object to see which properties are set for any particular event type).

The type property indicates what the event does. The following table lists its possible values:

Event Type Description collapse A tree item was collapsed. The item property points to the tree item being collapsed. Cancelling this event will prevent the tree item from collapsing. expand A tree item was expanded. The item property points to the tree item being expanded. Cancelling this event will prevent the tree item from expanding. click A tree item was clicked. The item property points to the tree item being clicked. Cancelling this event will prevent the tree current selection from changing. dblclick A tree item was double-clicked. The item property points to the tree item being clicked. Note the "click" event will fire twice before "dblclick" fires. This is normal. context A tree item was right-clicked. The item property points to the tree item being clicked. This might be used to open a context menu at the mouse position. beforedrag One or more tree items are about to be dragged. The item property points to the tree item about to be dragged. In case of a multiple selections, use the RasterTree.getSelectedItems() method to know which items are being dragged. Cancelling this event will prevent the drag operation from occurring. over A value is being dragged over a tree item. The item property points to the tree item currently under the mouse pointer. The dragValue property contains the value being dragged over the item. The position property indicates where the dragged value is about to be dropped in relation to the tree item.

If the event handler wishes to accept the dragValue at the current position, it must invoke RasterEvent.accept() to signal the control to highlight the item as a potential drop target (i.e. draw insertion line or shaded box at the item's location).

The event handler may overwrite the current position by passing a new position to the accept() method. If the event handler does not invoke accept(), the item will not be highlighted as a potential drop target, nor the "drop" event will fire on the item if the mouse button is released over the item.
drop A value was dropped over an item. The item property points to the tree item receiving the drop. The dragValue property contains the value dropped over the item. The position property indicates where the dragValue was dropped in relation to the item.

Moving Local Items

When dragging and dropping items inside the same control, the drag operation is said to be "local". In such case, the control's default behavior is to reorganize the dropped items automatically after the event handler returns from a "drop" event. If the event handler wishes to prevent the default "reorganize" behavior, it must invoke RasterEvent.cancel() before it returns.


Example: Hooking up a tree event handler
var tree = new RasterTree("myDiv", ICONS16.COMPUTER, "My Computer");
tree.setEventHandler( myHandler );  //assign event handler

...

function myHandler( evt )
{
    switch ( evt.type )
    {
       case "click"    : alert ( evt.item.text + " was clicked" );
                         break;
    }
}

See Also

Home Examples Download License
 
Copyright © 2010-2017 Edwin R. López