Re: Help for actionmanager and actionmainmenubar component.
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Mar 2006 17:56:12 +0200
"Cooper" <cooper@xxxxxxxxxxx> wrote in message
news:IkvWf.38964$nz4.37043@xxxxxxxxxxxxxxxxxxxxxxxx
i need help about ActionManager and ActionMainMenuBar component.
So, i have created a menu with this components and i need to
enable/disable some menu item (of this menu) at runtime.
Help me posting some example code for to do it?
The idea of actions is to reverse the logic that enables or disables
your controls. Instead of catching some event and recomputing the
control's state, you attach an action and _wait_. You wait until its
OnUpdate event is fired (which will happen automagically). In the
handler for that, you enable or disable _the action_ and all controls
that listen to it will follow.
So, let's say you have a menu item mnuFileClose that refers to an
action cmdFileClose. You write a handler for the action's OnUpdate
event which checks that a file is open - because otherwise, you can't
close it. (All names are approximate. I don't know how to tell if
there is a file open; you do.)
The sample code then becomes something like
procedure TFActiveMenuDemo.UpdateFileClose(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(ActiveDocument);
end;
The biggest trick is getting all the components (and the ActiveDocument
property) set up right so that it really becomes this easy.
Groetjes,
Maarten Wiltink
.
- References:
- Prev by Date: Re: Power arithmetic function to C#
- Next by Date: Re: Power arithmetic function to C#
- Previous by thread: Help for actionmanager and actionmainmenubar component.
- Index(es):
Relevant Pages
|