MenuOverview - robmcmullen/peppy GitHub Wiki
The menu and toolbar systems in peppy are integrated together and use the same processing chain. (KeyboardProcessing is also related, but processed in a separate handler.) A action will not know if it was called using the menubar or the toolbar (or the keyboard, for that matter). So, if you need separate functionality depending on where the action was called, make it separate actions.
Menus and toolbars are dynamically updated depending on the major mode of the current file. Switching between major modes will cause the menubar and toolbar to update themselves so that they provide only actions that are applicable to that major mode. This reduces clutter of the user interface.
The menu names and groupings attempt to follow the Mac OSX User Interface Guidelines. By default, the following menubar entries are created for all major modes: ||Menu Name||Relative Position|| ||File||0|| ||Edit||0.001|| ||View||0.003|| ||Tools||0.004|| ||Transform||0.005|| ||Documents||1000.1|| ||Window||1000.2|| ||&Help||1000.3|| The relative position is used to determine the ordering of menus when new menus are added. For user menus, a relative position in the range between 1 and 1000 should be used so as not to conflict with the default menus.
Note that if there are no items to display in a menu because the major mode doesn't have any actions that are contained in that menu, the menu will be left off of the menubar. For example, the Transform menu is typically used only for major modes that are for editing text, so if you're in MPDMode, for instance, the Transform menu won't show up.
The default menu location is specified here as a tuple containing the menu path (separated by / characters) and a number between 1 and 1000 representing the position within the menu. A negative number means that a separator should appear before the item.
When a major mode is busy, it is still possible that commands could be executed on the mode. I've tried to handle this by creating the Buffer.busy attribute, but this depends on the action using the BufferBusyActionMixin. It might be better if the menu system itself disabled actions that operated on the buffer based on that state, rather than the action having to declare enabled or not. Could this simply be based on the Enable state of the major mode itself? This would require that actions declare whether or not they operate on a major mode or if they are application wide actions.