Check Menu item and toolbar button out of sync

Fulvio Senore <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
I have a problem that I cannot solve. There must be something very 
simple that I am overlooking but I cannot find it.

I have a program with some menu entries (of course). Some of them are 
check items and one is replicated in a toolbar button that uses the same 
ID. I can mix menu clicks and toolbar button clicks and both elements 
stay in sync: if I check the menu item the button becomes pressed, for 
instance.

Now I added another check menu entry with a related toolbar button, 
again with the same ID. Both the menu entry and the toolbar button call 
the same event handler, as expected, but they are not in sync. If I 
check the menu item the toolbar butto does not become pressed and so on.

I have checked many times the code for these two commands and I can't 
see any difference, but this new one does not sync the UI elements.

Here is the code that creates the menu entries:

m_MenuView->Append(ID_VIEW_HOTSPOTS, _("Hotspots"), wxEmptyString, 
wxITEM_CHECK);

m_MenuView->Append(ID_VIEW_GRID, _("Grid"), wxEmptyString, wxITEM_CHECK);

and here is the code that creates the toolbar buttons:

wxBitmap 
itemtool30Bitmap(itemFrame1->GetBitmapResource(wxT("graphics/tlbHotspots.png")));
wxBitmap itemtool30BitmapDisabled;
m_Toolbar->AddTool(ID_VIEW_HOTSPOTS, _("Show Hotspots"), 
itemtool30Bitmap, itemtool30BitmapDisabled, wxITEM_CHECK, _("Show 
Hotspots"), wxEmptyString);

wxBitmap 
itemtool1Bitmap(itemFrame1->GetBitmapResource(wxT("graphics/tlbGrid16.png")));
wxBitmap itemtool1BitmapDisabled;
m_Toolbar->AddTool(ID_VIEW_GRID, _("Show Grid"), itemtool1Bitmap, 
itemtool1BitmapDisabled, wxITEM_CHECK, _("Show Grid"), wxEmptyString);

The "Show Hotspots" UI elements stay in sync, the "Show Grid" UI 
elements do not stay in sync.

I am building this un Windows.

Thanks in advance.

Fulvio Senore

-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/91562669-9b0f-40a7-8dea-244c39f14c69%40fsoft.it.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.