Handling Complex Menus?

D

Dave Veeneman

I've just finished an app with some fairly complex menu handling. Lots of
different groups of items to be enabled/disabled depending on user activity.
My code works fine, but it's really ugly. A long change of switch-case
statements. There has got to be a better way, without spending three weeks
factoring the menus into classes.

Are there any good resources (articles, book chapters) that suggest simple
ways to organize menu-handling, other than the obvious switch case? Thanks.
 
E

Eric Newton

I'm running into a similar shortcoming with TreeViews with Context menus
based on what the Node's Tag is.
 
D

Dave Veeneman

FWIW, my approach has been to define groups of menu items based on
application state, and to enable or disable the appropriate group(s) as
state changes. It works, but it's pretty ugly.

My Main form is handling all menu chores, which leads to a lot of chatter
between Main, its child forms, and my app controller. I'm thinking about
delegating out a lot of the menu chores to the child forms-- each child
should know how it affects menus, and it should instruct Main how to set
menus when the child form loads. That should provide a better distribution
of responsibilities and break up the switch case bottleneck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top