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

Fix #3868 - Menu key does not work in Project Panel #3871

Closed
wants to merge 1 commit into from
Closed

Fix #3868 - Menu key does not work in Project Panel #3871

wants to merge 1 commit into from

Conversation

luisffranca
Copy link
Contributor

If the context menu is generated from the keyboard (for example, by the Menu key), then the x- and y-coordinates are -1 and the application should display the context menu at the location of the current selection.

@@ -44,8 +44,8 @@
#define INDEX_LEAF 5
#define INDEX_LEAF_INVALID 6

#define GET_X_LPARAM(lp) LOWORD(lp)
#define GET_Y_LPARAM(lp) HIWORD(lp)
#define GET_X_LPARAM(lp) static_cast<short>(LOWORD(lp))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't those already defined in Windows headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CookiePLMonster Yes, you're right. I've included the header now. Thanks!

@DavidHansen-0x454d43
Copy link

@luisffranca This change doesn't work for me... GetCursorPos(&p) gets the current position of the mouse cursor, and not the position of the selected treeview item. In my testing, your code will only pop up the apps menu if the mouse is positioned over a workspace item.

I think you need to use something like this, to grab the bounding rectangle of the selected item.

@luisffranca
Copy link
Contributor Author

@DavidHansen-0x454d43 Thanks for the tip! I've changed the code and now the apps menu will pop up when a treeview item is selected.

RECT selectedItemRect;
if (TreeView_GetItemRect(_treeView.getHSelf(), selectedItem, &selectedItemRect, TRUE))
{
showContextMenuFromMenuKey(selectedItem, selectedItemRect.left, selectedItemRect.top);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its working correctly now, good job @luisffranca !

My only suggestion would be to change the offset a bit so the apps menu doesn't entirely obscure the selected item:
showContextMenuFromMenuKey(selectedItem, (selectedItemRect.left+selectedItemRect.right)/2, (selectedItemRect.top+ selectedItemRect.bottom)/2);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidHansen-0x454d43 I've done the change you suggested, and it looks better now :) Thanks!

@donho donho self-assigned this Mar 17, 2018
@donho donho added the accepted label Jul 22, 2019
@donho donho added this to the 7.x (master) milestone Jul 22, 2019
@donho donho closed this in 69da7a7 Jul 22, 2019
kspalaiologos pushed a commit to kspalaiologos/notepad-plus-plus that referenced this pull request Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants