Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Enabling/disabling or showing/hiding of a ActioneMenuBar has no consequences for the actions on the menu bar. If you want to make some actions not available in a certain context/situation, you need to implement the "OnUpdate" event of either the action itself or the action list or action manager it is part of.</p> <p>For example, using the following OnUpdate event of your action manager, you can use a TCheckBox to decide which of two actions is currently activated. </p> <pre><code> if CheckBox1.Checked then begin Action1.Enabled:= False; Action2.Enabled:= True; end else begin Action1.Enabled:= True; Action2.Enabled:= False; end; </code></pre> <p>Imagine, both actions have the shortcut "Ctrl+A" assigned, this will mean that pressing Ctrl+A will only activate Action1 when CheckBox1 is not checked.</p> <p>However, there is still a problem. The VCL will stop looking for actions with a certain shortcut once it has found an action with the shortcut in an action manager or action list in the current form, even when the found action is not enabled.</p> <p>To solve this problem, you can use the OnUpdate event to dynamically set and reset the ShortCut property of actions like this:</p> <pre><code> if CheckBox1.Checked then begin Action1.Enabled:= False; Action1.ShortCut:= scNone; Action2.Enabled:= True; Action2.ShortCut:= ShortCut(ord('A'), [ssCtrl]); end else begin Action2.Enabled:= False; Action2.ShortCut:= scNone; Action1.Enabled:= True; Action1.ShortCut:= ShortCut(ord('A'), [ssCtrl]); end; </code></pre> <p>Using this code, pressing Ctrl+A will activate Action2, if CheckBox1 is checked and will activate Action1, if CheckBox1 is not checked. You don't need to explicitly call the OnUpdate event of an action list or action manager. The event is fired regularly when the application is idle and waiting for user input.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload