Re: Check Menu item and toolbar button out of sync

Vadim Zeitlin <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
On Tue, 17 Sep 2024 12:57:24 +0200 Fulvio Senore wrote:

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

 This doesn't happen automatically, actually. Typically you'd use
wxEVT_UPDATE_UI handler to do it: as it will be called for both the menu
item and the toolbar tool (because they have the same ID), it would set
their states to the same value.

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

 I.e. this is the expected behaviour if you do nothing else.

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

 You should be able to put a breakpoint on wxToolBarToolBase::Toggle() to
check where is it called from for the first tool.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
              https://www.tt-solutions.com/
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQQx+vLQdOwioQqkxtoG6kHeT2wehgUCZulxBAAKCRAG6kHeT2we
hskPAJ4sAZ3U1WoJ4KAk+gsQvO2WytvuTgCgqnjNXhfMgSLQnvuJ1T49c5Gubyo=
=rAPJ
-----END PGP SIGNATURE-----
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.