Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong message in TSysPopupStyleHook.WndProc #217

Closed
ricobautsch opened this issue Nov 9, 2017 · 5 comments
Closed

wrong message in TSysPopupStyleHook.WndProc #217

ricobautsch opened this issue Nov 9, 2017 · 5 comments
Assignees
Labels

Comments

@ricobautsch
Copy link

ricobautsch commented Nov 9, 2017

In TSysPopupStyleHook.WndProc the message MN_BUTTONDOWN is used.
This will close the PopupMenu by clicking down the mouse button, and afterwards the control under the mouse cursor gets the MouseUp event, which will result in different crazy behaviors.
I fixed my issue locally by using the MN_BUTTONDOWN_UP instead of MN_BUTTONDOWN.
I noticed, that windows itself always triggers the menu action, when user leaves the mouse button.

@RRUZ RRUZ self-assigned this Nov 21, 2017
@RRUZ RRUZ added the question label Nov 21, 2017
@RRUZ
Copy link
Owner

RRUZ commented Nov 21, 2017

Can you post your fix to check it?

luebbe added a commit to luebbe/vcl-styles-utils that referenced this issue Nov 22, 2017
- Use MN_BUTTONDOWN_UP instead of MN_BUTTONDOWN
@luebbe
Copy link
Contributor

luebbe commented Nov 22, 2017

I created a PR, because I can confirm that it fixes the problem for me.

@DrOfSpin
Copy link

DrOfSpin commented Aug 1, 2018

A vote for ricobautsch fix.
I found the same fix independently as I was trying to solve TStringGrid components scrolling after selecting popup menu items (positioned over the scrollbar), and noticed that events were triggering on MouseDown rather than MouseUP with Custom Styles enabled but was OK with Windows style.

@aivarsi
Copy link

aivarsi commented Dec 11, 2019

Unfortunately this fix messes up menus, when there are too many items to fit in the screen and scrolling is enabled. During scrolling ugly visual artifacts appear.

@aivarsi
Copy link

aivarsi commented Dec 11, 2019

I'm suggesting this patch:

@@ -1681,6 +1681,16 @@
             CallDefaultProc(Message2);
             exit;
           end;
+        end;
+      end;
+
+    MN_BUTTONDOWN:
+      begin
+        { we should calc item/button pressed with mouse position }
+        LInitPos.X := 0;
+        LInitPos.Y := 0;
+        FKeyIndex := GetItemClicked(LButton, LInitPos);
+        case LButton of
           1:
           begin
             { Scroll up menu }

basically, it separates functionality so that MN_BUTTONDOWN does scrolling and MN_BUTTONDOWN_UP does menu item clicking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants