I have a menu that has so many menu items in the menu that there are scroll widgets that appear at the top & bottom of the menu. I'm using TestPartner to test the screen and choosing the menu item from the Main menu on the form TestPartner is returning the PopupMenuControlTrusted object for the popupmenu. Using the PopupMenuControlTrusted obect I need to be able to iterate through the tool items to find the item a specific item and bring it into view so that TestPartner can then click it.
The class used to create the menu is the UltraToolbarsManager
Can you get the parent tool that opened the context menu from the PopupMenuControlTrusted?
It doesn't look like there is an easy way to get from the PopupMenuControlTrusted to the menu which opened it. However, if you have one of the tool's on the menu, you can go to the Owner of that tool to get the menu. You can also use the UltraToolbarsManager.ToolFromPoint method to find out which tool is under the mouse on the menu. Also, you can use ToolBase.BringIntoView() to bring any tool into view if it is scrolled out of view on the menu.
It was too straight forward but I did figure it out.
PopupMenuControlTrusted _popupMenu; ToolBase _selectedMenuItem; protected override bool FindMenuItem(string searchCaption) { _selectedMenuItem = null; IUltraControlElement menu = (IUltraControlElement)_popupMenu; UltraToolbarsManager manager = (UltraToolbarsManager)menu.MainUIElement.UltraControl; PopupMenuTool curItem = manager.ActiveTool as PopupMenuTool; if (curItem != null) { foreach (ToolBase tool in curItem.Tools) {
/* Clean up string and remove ampersand */ string toolCaption = PrepareCompareString(tool.CaptionResolved, true, true, true, true, true, true, false, false, false, false, true); if (StringMatch(searchCaption, toolCaption)) { _selectedMenuItem = tool; } } } return (_selectedMenuItem != null); } }
Hi,
I have the same problem because I want to get a UltraToolbaarManager from PopupControlTrustedMenu...
Do you have solved it and can you please help me?...
Antonio Atzeni
Did you try the code I posted, I believe that was my solution. One you get the menu item you then call bringintoview on it