commit 98d0fd6e11d50568d16a67b207ac30aa8d49acf2
parent 749c56f48b51f12b2822391bee316cd51e5be23e
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sun, 21 Aug 2016 14:26:10 -0700
listview: fix Shift+F10 on Windows (bis)
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/listview.cpp b/src/listview.cpp
@@ -307,7 +307,7 @@ bool ListView::onContextMenu(HWND dialog, int x, int y)
const int headerHeight = 0;
#endif
- if(point.y < headerHeight) {
+ if(point.y < headerHeight && x != -1) {
if(m_customizable) // show menu only if header is customizable
headerMenu(x, y);
return true;
@@ -316,12 +316,13 @@ bool ListView::onContextMenu(HWND dialog, int x, int y)
int index = itemUnderMouse();
#ifdef ListView_GetItemPosition // unsuported by SWELL
- if(x == 0xffff) {
- // adjust context menu position when using Shift+F10 on Windows
- index = max(0, currentIndex());
+ // adjust the context menu's position when using Shift+F10 on Windows
+ if(x == -1) {
+ index = currentIndex();
+ // find the location of the current item or of the first item
POINT point{};
- ListView_GetItemPosition(handle(), translate(index), &point);
+ ListView_GetItemPosition(handle(), translate(max(0, index)), &point);
ClientToScreen(handle(), &point);
x = point.x;
y = point.y;