Delphi: disable 1 Action from action list

This is ridiculous :) but how to do something like ActionList1.MyAction.Enable:=false ?

There are actions for buttons in the action list if the button is invisible. I need to disable its action (if this is not done and create a shortcut, then the procedure will be executed).

Maybe I'm doing something wrong, but I did not assign actions to the buttons. I have only a list of actions with actions. Each action has a shortcut. When this shortcut is clicked, the action is executed and the procedure is running. If you press the button โ†’, the same procedure will be performed.

State:=asSuspended is for the entire list of actions.

Thanks!!!

+4
source share
2 answers

You must assign an Action property and manage everything with an action. Set the action you want to disable, invisible, etc., and the button follows the example.

Do not set the OnClick event handler on the button, use the appropriate action event instead. Use the OnUpdate action to set properties such as Visible, Enabled, etc., Basically everything that changes at runtime.

+5
source

TActionList is a list containing one or more TAction .

TAction has the following properties:
AutoCheck
Inscription
Verified
Included
Groupindex
HelpContext
HelpKeyword
HelpType
hint
ImageIndex
SecondaryShortCuts
Shortcut
Visible

Enabled should work fine if you follow David's advice and do everything using a TActionList.

Otherwise, if taction.enabled does not work for you, you can always check if the setting actionxxxx.shortcut := ''; .
If not, another shortcut intercepts a keystroke.

Cm:
http://docwiki.embarcadero.com/VCL/XE/en/ActnList.TAction
http://docwiki.embarcadero.com/VCL/en/ActnList.TActionList

+1
source

All Articles