Delphi TActionMainenuBar - 2nd-level submenu menu item is disabled - delphi

With Delphi XE5 I am converting a TMainMenu to a TActionMainMenuBar but I am having issues with a submenu node within a category being disabled at runtime, for example in my 'File' category. Most 'File' category items are actions dragged over from the Action Manager, but I also want to group two of those actions under a submenu node within the File menu. With TMainMenu I would simply use Create submenu and edit the resulting TMenuItem caption, but I see that the TActionMainMenuBar has context items for each client item, and this is what I've tried to use. The result is that the layout looks ok but the submenu item is disabled at runtime (presumably because it does not have an action).
This is what I see at design time - I've created the 'Batch Reporting' item myself using 'Add item' in the object inspector.
This is what I see at run time, the item is disabled.
This is what I see in the object inspector with my context items included.
Should I be setting a special property on the 'Batch Reporting' item to give it a 'no action' status? Or am I forced to use an action with a 'do nothing' OnExecute?

I've found the answer - I was using the 'Context Items' of the submenu, I should have been using 'Items' as shown below. Very confusing!

Related

Trying to add items to a TRadioGroup but no Item Editor or Items property is available

I'm trying to create a 4-button radio group on a Form using the TRadioGroup component. I can add the radio group, but I can't add any items to it.
The documentation gives two ways of doing this: the 1st way is to right-click the group box and select "Item Editor", and the 2nd way is to edit the Items property in the Object Inspector. However I have no Item Editor selection available on right-click, and no Items property in the Object Inspector.
Is there something in the setup that I've missed here, or will I have to resort to using a TGroupBox and adding individual TRadioButton control to it?

Dynamically Modify ActionMenuBar Items When Category is Clicked

I am creating a menu using an ActionManager and an ActionMenuBar. I want to add and subtract items from the menu when the top-level menu node is clicked but I can't find a clean way to do this. For example, I want to create a top-level menu "Windows" that hosts items corresponding to every modeless form. I can create the top-level "Windows" menu by creating a Category named Windows in the ActionManager and dragging "Windows" to the menu bar. When "Windows" is clicked I would then like to populate Items property with TActionClientItems corresponding to the application's modeless forms. I do know the mechanics of dynamically adding action clients at runtime (for example, in the form's oncreate event) but I can't find an action that fires when a Category (in this case, "Windows") is clicked.
I could work around this by updating the menu whenever a form is hidden or shown, but this seems inelegant compared to updating the menu on demand. I tried attaching an action to the "Windows" actionclientitem but the action's onexecute doesn't fire (apparently because it is a Category).
The failure of the onexecute handler to be called can be demonstrated with the following steps:
In Actionmanager create action named "Action1" and assigned its
category property to "Windows".
Drag the "Windows" category to
the menubar.
Create an action named WindowAction and assigned no
category to it.
Add "Showmessage('x');" to the OnExecute of
WindowAction.
In designer click on ActionManager1->ActionBars->0->Items-."0-Windows" (which is TActionClients[0]). Set TActionClients[0].Action := WindowAction.
Correct the caption of TActionClients[0] so that it is again "Windows".
Run program, click "Windows" on menu and showmessage not shown.

How to disable menu, sub-menu in ActionMainMenuBar?

Using: Delphi XE3, VCL Forms application
I have a menu containing a sub-menu in a ActionMainMenuBar. How can I via code:
disable the menu
disable the sub-menu
Create a 'TAction' per menu/submenu that you want to enable disable. Do not assign them to any category.
Create an 'OnExecute' event handler for these actions, so that these can be enabled. You don't have to put any code in the handler, a comment ('//') is enough for the IDE to not to delete the handlers.
Select the 'TActionClient' that represents the menu/submenu from the form designer, just click on the item.
Assign one of the actions to its 'Action' property in the object inspector.
Enable/disable the action associated with the 'TActionClient' that represents the menu/submenu at run time for the menu/submenu to be enabled/disabled accordingly.
By using the 'enabled' property of the menu? or the menu-item that is the starting point of the submenu...
You can actually disable it at runtime (in Delphi 7 anyway) if you know the index of the top-level menu item for the category as follows:
ActionMainMenuBar.ActionControls[2].Enabled := False;
ActionControls[2] would be the category showing as a top-level menu item (after dragging the category onto ActionMainMenuBar from ActionManager.

FireMonkey: how to suppress default popup menu

I've got a TMemo with an associated TPopupMenu on a FireMonkey form.
When I rightclick on the memo, I get my own popup menu, but after my popup disappears I still get the default popup (the one that says cut, copy, paste, select all).
How do I disable the default menu, or can I add my own items to the default menu perhaps?
I can't reproduce this behavior. Here's what I tried:
File->New->FireMonkey HD Application
Drop a TMemo and TPopupMenu on the form
Assign PopupMenu to Memo1.PopupMenu in the Object Inspector
Create two menu items in the PopupMenu, and assign them both the same OnClick event (generated in the Object Inspector). I left the default caption of MenuItem1 and MenuItem2 in the Caption of both items.
Wrote a simple MessageDlg that displays TMenuItem(Sender).Caption with a single Ok button in the OnClick handler.
Run the application, right-click Memo1, and choose either menu item
I get a single menu displayed with my two items (MenuItem1 and MenuItem2). Choosing either item displays the appropriate Caption in a message dialog, and clicking Ok in that dialog. There is no default popup menu displayed.
EDIT: Found it for you. This is a bug fixed in Update 3 - see the list of bug fixes in Update 3, and search for 98705, or scroll through until you reach the section on FireMonkey\Components (it's the second or third entry under that section).

Delphi 2010 Action Manager & Main Menu Bar

I'm trying to use the Action Manager and Action Main Menu Bar in Delphi 2010 an I have no idea how to make this work. I've tried looking at the examples that come with Delphi 2010 and I can't seem to figure this out.
I've tried playing around with the examples. I've been able to add an image to the Image List component and set that item to the new item index. At design time it displays properly at runtime it reverts back to the original.
I'd like to learn how to use the Action Manager and Action Main Menu Bar but I can find any help on these topics. Is there a tutorial on how to use the Action Manager and Action Main Menu Bar?
Drag and drop a ActionManager, a ActionMainMenuBar and a ImageList on your form.
Doubleclick the ImageList, you get the Imagelist Editor. Use the Add-button to add your icons (make sure their sizes are the same as the Height and Width properties that are set in the ImageList-control).
Set the Images-property of the ActionManager to your ImageList and set the ActionManager-property of your ActionMainMenuBar to your ActionManager.
Doubleclick the ActionManager, go to the tab 'Actions' and add new actions by the 'New'-button.
Click each Action in the ActionManager and set each action's properties, at least: ImageIndex (to choose an Icon), Caption and Category.
Note: A Category will serve as a main item in the menu (like File, Edit and View) and each Action will serve as menu item (like Save, Save as, Load). So set the Category property of all actions you want to belong to one main menu item to the same name. For instance give the actions 'Save' and 'Load' the category 'File' and give the actions 'Undo' and 'Redo' the category 'Edit'.
Doubleclick each Action in the ActionManager. You'll get the code editor. Type the code you want to perform when the user clicks this menu item. If you don't type any code or comment, the menu item will automatically be disabled when the application is running.
Now drag the categories from the ActionManager to the ActionMainMenuBar.
That's it.
I think Actions, Action Lists And Action Managers by Brian Long is a great start to explore the realm of actions.

Resources