Can I force menus attached to a menubar to close?

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
nlevisrael
In need of some credit
In need of some credit
Posts: 5
Joined: Tue Jan 08, 2008 10:31 pm

Can I force menus attached to a menubar to close?

Post by nlevisrael » Thu Feb 14, 2008 4:24 am

I've gotten to like the office ribbon, and I'm trying to achieve something vaguely similar by "attaching" a ChoiceBook to a menubar: that is, clicking on a menubar label triggers a choicebook SetSelection(), inside an OnMenuOpen event handler. Some of the menubar menus are "real" drop-down menus; the others I leave blank (i.e, I don't append any menuitems to them). It works OK, but I'm finding that if one of those empty menu labels is clicked, triggering OnMenuOpen, it grabs the mouse and keyboard focus and won't let other controls respond to certain events (they'll respond to clicks, but that's because clicks force the menu to close). What I need is a method that will dynamically close the menu which triggered the OnMenuOpen event (there's an OnMenuClose event but there doesn't seem to be a wxMenu::Close or wxMenuBar::Close member). If that's not doable, I suppose I could simulate a menubar with a panel, some static texts, and a few popup menus, but then is there some easy way to get the look of a menubar (background styles, button appearance, etc.)? Everything I've tried doesn't look right.
(using MSW, VC++ '05, 2.8.7)

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Mon Feb 18, 2008 12:58 am

I'm not sure I understand your question, but... You can focus a different wxWindow object (to close the menu), then programmatically open the target menu. It will happen so fast the user won't notice.

regards.
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

Post Reply