Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Tidy main context menu
MortenMacFly:
--- Quote from: dmoore on September 04, 2012, 02:45:33 pm ---At start up, the framework and each plugin should "register" the menu commands/popup/toolbar items it offers with a unique ID.
--- End quote ---
Exactly what I meant. Just that the menu's ID is automatically given by the wxMenu item, which is unique in itself. So IMHO there is no need to provide more information than the menu.
dmoore:
--- Quote from: MortenMacFly on September 04, 2012, 03:50:39 pm ---
--- Quote from: dmoore on September 04, 2012, 02:45:33 pm ---At start up, the framework and each plugin should "register" the menu commands/popup/toolbar items it offers with a unique ID.
--- End quote ---
Exactly what I meant. Just that the menu's ID is automatically given by the wxMenu item, which is unique in itself. So IMHO there is no need to provide more information than the menu.
--- End quote ---
You need persistent IDs for keybinder (which is why keybinder currently uses the menu label) and to let the user control whether certain items will or will not display. wxIDs like Menu ID's are dynamic, so this is a problem. (Even bigger problem for popup items).
MortenMacFly:
--- Quote from: dmoore on September 04, 2012, 04:15:52 pm ---You need persistent IDs for keybinder (which is why keybinder currently uses the menu label)
--- End quote ---
The label, maybe in combination with the parent item, is just fine - including for popup menus IMHO. I do it similar in another project of mine.
How would you do persistent ID's otherwise? (Maybe I misunderstood "persistent" - you don't mean globally unique ID's that don't change through sessions, do you?!)
dmoore:
--- Quote from: MortenMacFly on September 04, 2012, 04:56:12 pm ---
--- Quote from: dmoore on September 04, 2012, 04:15:52 pm ---You need persistent IDs for keybinder (which is why keybinder currently uses the menu label)
--- End quote ---
The label, maybe in combination with the parent item, is just fine - including for popup menus IMHO. I do it similar in another project of mine.
--- End quote ---
But it doesn't work for menus that dynamically update their label: e.g. "Find declaration of: 'NULL'"
The simplest thing to do would be to assign a unique XRCID (or equivalently "name" member) to every menu/toolbar/popup item. This would nicely tie in nicely to the wxWidgets event system. This would make it easy to find items in, say, a menu by using wxWindow::FindWindowByName, wxWindow::GetName etc.
EDIT: Turns out this isn't so simple -- I forgot MenuItem's aren't derived from wxWindow...
It might also be possible to have the SDK supply unique names using wxWindow::SetName, but would have to be careful not to break XRC based UI.
dmoore:
--- Quote from: MortenMacFly on September 04, 2012, 04:56:12 pm ---How would you do persistent ID's otherwise? (Maybe I misunderstood "persistent" - you don't mean globally unique ID's that don't change through sessions, do you?!)
--- End quote ---
So what would be so bad about this? To do this stuff we want to do, we need some mapping between a unique ID (that lets us store persistent information about the menu/popup/toolbar items such as keybindings and hidden state) and their run-time id's. We defacto do this right now using the label, but why not just take it a step further and use a unique ID?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version