CommandHandler in Menu Dropdown not firing

Topics: CAB & Smart Client Software Factory
Aug 25, 2006 at 9:37 AM
originally posted by: ForumUserRCC

I create via a ModuleController a main menu.
For a simple example, I create a "File" menu on the main menu, and under File I add a menu item called ABC.
For ABC, I add a dropdown item ZZZ, and on it I do the AddInvoker for "click".

I have another module set up with a CommandHandler for that ZZZ menu item.
But it never gets triggered.

However, if in my Shell.cs file, I put in a CommandHandler for that same ZZZ click - and it can be with no code, just the EventSubscription attribute and an empty method, THEN the one in my other module fires.

If I have another menu item under "File" - say A123 - and it has no dropdowns, and it has the AddInvoker, then it works as expected in other modules -- I don't need to put that "dummy" CommandHandler in the Shell.

Am I coding something incorrect when adding the dropdown?

Sample code that I have is as follows:


// Add a menu item to the File menu in the main menu
ToolStripMenuItem searchMenuItem = new ToolStripMenuItem();
searchMenuItem.Name = CommandNames.s_sActionsSearch;
searchMenuItem.Text = "Search";
fileMenuItem.DropDownItems.Add(searchMenuItem);


// Add a Dropdown item into the Search item added above

ToolStripMenuItem basicMenuItem = new ToolStripMenuItem();
basicMenuItem.Name = CommandNames.s_sActionsSearchBasic;
basicMenuItem.Text = "Basic Search";
WorkItem.RootWorkItem.CommandsCommandNames.s_sActionsSearchBasic.AddInvoker(basicMenuItem, "Click");
searchMenuItem.DropDownItems.Add(basicMenuItem);
Aug 30, 2006 at 2:37 AM
originally posted by: ForumUserRCC

The problem was where i was adding the Commands and when. I had them both in a Module's WorkItem and in the Rootitem, but the WorkItem ones were getting added first, and the scope was local to the Workitem.

I added "dummy" Commands in the RootItem earlier, and thenallowed the modules to add their items. By doing this, all modules could create CommandHandlers where needed.
Nov 16, 2006 at 2:52 PM
originally posted by: Jrad

Hi,
Any chance you could post a code sample of your solution as I appear to be having w similar problem.
Thanks
John