ConnectTreeNotify

>>-aMessageExtensions~ConnectTreeNotify(--id--,--"--+-BEGINDRAG---+--"-->
                                                    +-BEGINRDRAG--+
                                                    +-BEGINEDIT---+
                                                    +-ENDEDIT-----+
                                                    +-DEFAULTEDIT-+
                                                    +-EXPANDING---+
                                                    +-EXPANDED----+
                                                    +-DELETE------+
                                                    +-KEYDOWN-----+
                                                    +-SELCHANGING-+
                                                    +-SELCHANGED--+

>--+---------------+--)----------------------------------------><
   +-,--msgToRaise-+


The ConnectTreeNotify method connects a particular WM_NOTIFY message for a tree view control with a method. The WM_NOTIFY message informs the dialog that an event has occurred in the tree view.

Arguments:

The arguments are:

id

The ID of the tree view control of which a notification is to be connected to a method.

event

The event to be connected with a method:

BEGINDRAG

A drag-and-drop operaton was initiated. See DefTreeDragHandler for information on how to implement a drag-and-drop handler.

BEGINRDRAG

A drag-and-drop operaton involving the right mouse button was initiated. See DefTreeDragHandler for information on how to implement a drag-and-drop handler.

BEGINEDIT

Editing a label has been started.

ENDEDIT

Label editing has ended.

DEFAULTEDIT

This event connects the notification that label editing has been started and ended with a predefined event-handling method. This method extracts the newly entered text from the notification and modifies the item of which the label was edited. If this event is not connected you must provide your own event-handling method and connect it with the BEGINEDIT and ENDEDIT events. Otherwise, the edited text is lost and the item remains unchanged.

When you specify this event, omit the msgToRaise argument.

EXPANDING

An item is about to expand or collapse. This notification is sent before the item has expanded or collapsed.

EXPANDED

An item has expanded or collapsed. This notification is sent after the item expanded or collapsed.

DELETE

An item has been deleted.

KEYDOWN

A key was pressed inside the tree view. This notification is not sent while a label is being edited.

SELCHANGING

Another item is about to be selected. This notification is sent before the selection has changed.

SELCHANGED

Another item was selected. This notification is sent after the selection was changed.

msgToRaise

The message that is to be sent whenever the specified notification is received from the tree view control. Provide a method with a matching name. If you omit this argument, the event is preceded by On.

Return value:

The return codes are:

0

No error detected.

-1

The resource ID could not be resolved or the event argument is incorrect.

1

The message was not connected correctly.

Example:

The following example connects the selection-changed event for the tree view FileTree with method NewTreeSelection and displays the text of the new selection:

::class MyDlgClass subclass UserDialog inherit MessageExtensions

::method Init
  self~init:super(...)
  self~ConnectTreeNotify("FileTree", "SELCHANGED", "NewTreeSelection")

::method NewTreeSelection
  tc = self~GetTreeControl("FileTree")
  info. = tc~ItemInfo(tc~Selected)
  say "New selection is:" info.!text

Note:

  1. Connections are usually placed in the Init or InitDialog method. If both methods are defined, use init as the place for this connection - but not before init:super has been called.

  2. The event-handling method connected to ENDEDIT receives two arguments: the item handle of which the label has been edited and the newly entered text. Example:

    ::method OnEndEdit
      use arg item, newText

  3. The event-handling method connected to KEYDOWN receives two arguments: the control ID of the tree view control and the virtual key code pressed. Use the method KeyName of the VirtualKeyCodes class to get the name of the key. Note that your class must inherit from the VirtualKeyCodes class to use the KeyName method. Example:

    ::method OnKeyDown
      use arg id, vkey
      say "Key" self~KeyName(vkey) "was pressed."

  4. The event-handling method connected to EXPANDED or EXPANDING receives three arguments: the control ID of the tree view control, the tree item expanded or collapsed, and a string that indicates whether the item was expanded or collapsed. Example:

    ::method OnExpanding
      use arg id, item, what
      say "Item with handle" item "is going to be" what

  5. The event-handling method connected to BEGINDRAG or BEGINRDRAG receives three arguments: the control ID of the tree view control, the tree item to be dragged, and the point where the mouse cursor was pressed (x and y positions, separated by a blank). Example:

    ::method OnBeginDrag
      use arg id, item, where
      say "Item with handle" item "is in drag-and-drop mode"
      parse var where x y
      say "The drag operation started at point ("x","y")"