OnBeginLabelEdit - AbstractTreeView
Fired just prior to the user starting in-line editing of an item label
Type: Event
Parameters
| Parameter | Type | Description |
|---|---|---|
| hItem | Handle | Item handle |
| ByRef bCancel | Boolean | Can be used to cancel the event by returning True |
Syntax
Procedure OnBeginLabelEdit Handle hItem ByRef Boolean bCancel
Description
If a user performs in-line editing of the label (TreeEditLabelsState must be True), the OnBeginLabelEdit event will be fired just prior to the user starting the editing.
The existing label value can be obtained by calling ItemLabel.
Sample
Procedure OnBeginLabelEdit Handle hItem Boolean ByRef bCancel
Handle hRoot
// if user is editing the root, don't allow and declare an error
Get RootItem to hRoot
If (hItem=hRoot) Begin
Error DFERR_OPERATOR "Cannot change the root Label"
Move True to bCancel
End
End_Procedure
Procedure OnEndLabelEdit Handle hItem String sNewLabel Boolean bWasCanceled Boolean ByRef bCancel
String sOriginalLabel
If (not(bWasCanceled)) Begin
// get old value of the label
Get ItemLabel hItem to sOriginalLabel
// don't allow edit to be blank
If (sNewLabel="") Begin
Error DFERR_OPERATOR "Blank labels not allowed"
Move True to bCancel
End
Else If (sOriginalLabel=sNewLabel) Begin
// if no change, complain
Error DFERR_OPERATOR "You did not change anything"
End
End
Else Begin
// This really isn't an error, but you get the idea
Error DFERR_OPERATOR "Cancelled by User"
End
End_Procedure
Sample
This sample demonstrates the use of the bCancel parameter to cancel the editing of a TreeView item label.
Procedure OnBeginLabelEdit Handle hItem Boolean ByRef bCancel
Move True to bCancel
End_Procedure
See Also
OnEndLabelEdit | pbCancelEdit | TreeEditLabelsState | ItemLabel