RAD Studio |  |

Updating Actions
See Also
Collapse All

When the application is idle, the OnUpdate event occurs for every action that is linked to a control or menu item that is showing. This provides an opportunity for applications to execute centralized code for enabling and disabling, checking and unchecking, and so on. For example, the following code illustrates the OnUpdate event handler for an action that is "checked" when the toolbar is visible:

Copy Code

    procedure TForm1.Action1Update(Sender: TObject);
    begin
    { Indicate whether ToolBar1 is currently visible }
    (Sender as TAction).Checked := ToolBar1.Visible;
    end;

Copy Code

    void __fastcall TForm1::Action1Update(TObject *Sender)
    {
    // Indicate whether ToolBar1 is currently visible
    ((TAction *)Sender)->Checked = ToolBar1->Visible;
    }

Warning: Do not add time-intensive code to the OnUpdate event handler. This executes whenever the application is idle. If the event handler takes too much time, it will adversely affect performance of the entire application.
See Also

TActionList

TAction

TActionLink

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!