Don't mangle ampersands in wxToolBar tooltips under MSW
Preserve the ampersands in the string, which is consistent with wxGTK behaviour and less surprising than the default behaviour, which creates mnemonics in the tooltips that are, of course, perfectly useless, as they can't be activated from keyboard anyhow. Turn on TTS_NOPREFIX, which is already used by wxToolTip, to fix this. Closes #18899.
This commit is contained in:
@@ -452,6 +452,20 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size)
|
||||
MSWSetPadding(m_toolPacking);
|
||||
}
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
// MSW "helpfully" handles ampersands as mnemonics in the tooltips
|
||||
// (officially in order to allow using the same string as the menu item and
|
||||
// a toolbar item tip), but we don't want this, so force TTS_NOPREFIX to be
|
||||
// on to preserve all ampersands.
|
||||
HWND hwndTTip = (HWND)::SendMessage(GetHwnd(), TB_GETTOOLTIPS, 0, 0);
|
||||
if ( hwndTTip )
|
||||
{
|
||||
long styleTTip = ::GetWindowLong(hwndTTip, GWL_STYLE);
|
||||
styleTTip |= TTS_NOPREFIX;
|
||||
::SetWindowLong(hwndTTip, GWL_STYLE, styleTTip);
|
||||
}
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user