From fefd9de52aaaae58d3c0150cbd19f0e403ba92ce Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 11 Dec 2017 10:17:59 +0100 Subject: Windows QPA: Emulate aboutToHide(), aboutToShow() signals of QPlatformMenu Wrap the call to TrackPopupMenu accordingly. Complements 7849aa6e96aa923fca5523afc8cf88edcc0bcf90. Task-number: QTBUG-64628 Change-Id: Ia370e566266e96ab690ce5ed41d06dea7cafd4e4 Reviewed-by: J-P Nurmi Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsmenu.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows/qwindowsmenu.cpp') diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index 4e1997c4f8..72f11d54b4 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -686,9 +686,16 @@ void QWindowsPopupMenu::showPopup(const QWindow *parentWindow, const QRect &targ bool QWindowsPopupMenu::trackPopupMenu(HWND windowHandle, int x, int y) { lastShownPopupMenu = this; - return TrackPopupMenu(menuHandle(), + // Emulate Show()/Hide() signals. Could be implemented by catching the + // WM_EXITMENULOOP, WM_ENTERMENULOOP messages; but they do not carry + // information telling which menu was opened. + emit aboutToShow(); + const bool result = + TrackPopupMenu(menuHandle(), QGuiApplication::layoutDirection() == Qt::RightToLeft ? UINT(TPM_RIGHTALIGN) : UINT(0), x, y, 0, windowHandle, nullptr) == TRUE; + emit aboutToHide(); + return result; } bool QWindowsPopupMenu::notifyTriggered(uint id) -- cgit v1.2.3