Skip to content

OnChange - cTextEdit

Called whenever the value of the control is changed

Type: Event

Syntax

Procedure OnChange

Description

Fires whenever the value of the control is changed, either by the user (a keypress or mouse event) or by a programmatic function that emulates user input.

OnChange is a good place to toggle things that are related to user input, such as toggling the state of toolbar buttons.

Col 1 Col 2
Note: The OnChange event should not be used to change focus. If you want to respond to a change in a combo based on a user selection, it is suggested you augment other procedures such as OnLinkClicked.

Sample

This sample determines whether undo and redo operations can be performed during the current state of the control and set the pbEnabled property of toolbar buttons (class cToolbarButton) in response.

Procedure OnChange
    if (pbCanUndo(Self) = True) ;
        set pbEnabled of (oUndo(oToolbar(Self))) to True
    else ;
        set pbEnabled of (oUndo(oToolbar(Self))) to False

    if (pbCanRedo(Self) = True) ;
        set pbEnabled of (oRedo(oToolbar(Self))) to True
    else ;
        set pbEnabled of (oRedo(oToolbar(Self))) to False
End_Procedure  // OnChange