Dynamic Updating of Action Visibilities

Problem: You want to change an action’s visible property and does so in its OnUpdate event handler, but it doesn’t seem to work. Once an action is hidden it can’t seem to become visible again.  Solution: By design Delphi won’t invoke OnUpdate event handlers for actions that have their Visible property set to false. Instead, one has to override the form’s UpdateActions method tod do the dynamic checking and setting of Visibility.

  TMainForm = class(TForm)
    procedure TMainForm.UpdateActions; override;


procedure TMainForm.UpdateActions;
  // Those actions are updating their visible
  // properties and must therefore be updated
  // here and not in their respective update
  // event handlers. This is due to the fact
  // that invisible actions are not concidered
  // by the inherited UpdateActions loop.
  // This is by design according to CodeGear.

  CancelAction.Visible := IsRunning;
  StartAction.Visible := not CancelAction.Visible;

More information can be found on the Delphi forum, here: https://forums.embarcadero.com/thread.jspa?threadID=18206&tstart=90

RSS feed | Trackback URI

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> in your comment.