summaryrefslogtreecommitdiff
path: root/plugingui/nativewindow_win32.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-05-09 20:52:43 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2019-05-09 20:52:47 +0200
commit15faa626f7df7a3024dda5d11001347ed4573568 (patch)
treeaad5c44d8906caef72e76f767b6895c0a4682a46 /plugingui/nativewindow_win32.cc
parent751f01eea8c40f70d412e691e6677d3daae54c7a (diff)
Add tooltip buttons to frames.
Diffstat (limited to 'plugingui/nativewindow_win32.cc')
-rw-r--r--plugingui/nativewindow_win32.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/plugingui/nativewindow_win32.cc b/plugingui/nativewindow_win32.cc
index 5cfb179..0dc30de 100644
--- a/plugingui/nativewindow_win32.cc
+++ b/plugingui/nativewindow_win32.cc
@@ -35,6 +35,16 @@
namespace GUI
{
+static BOOL trackMouse(HWND hwnd)
+{
+ TRACKMOUSEEVENT ev{};
+ ev.cbSize = sizeof(ev);
+ ev.dwFlags = TME_HOVER | TME_LEAVE;
+ ev.hwndTrack = hwnd;
+ ev.dwHoverTime = 1;
+ return TrackMouseEvent(&ev);
+}
+
LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
WPARAM wp, LPARAM lp)
{
@@ -89,9 +99,20 @@ LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
// return 0;
case WM_MOUSEMOVE:
{
+ trackMouse(native->m_hwnd);
auto mouseMoveEvent = std::make_shared<MouseMoveEvent>();
mouseMoveEvent->x = (short)LOWORD(lp);
mouseMoveEvent->y = (short)HIWORD(lp);
+ native->last_mouse_position = { mouseMoveEvent->x, mouseMoveEvent->y };
+
+ if(!native->mouse_in_window)
+ {
+ auto enterEvent = std::make_shared<MouseEnterEvent>();
+ enterEvent->x = native->last_mouse_position.first;
+ enterEvent->y = native->last_mouse_position.second;
+ native->event_queue.push_back(enterEvent);
+ native->mouse_in_window = true;
+ }
native->event_queue.push_back(mouseMoveEvent);
}
break;
@@ -295,8 +316,17 @@ LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
DeleteObject(ourbitmap);
}
}
+ break;
- return DefWindowProc(hwnd, msg, wp, lp);
+ case WM_MOUSELEAVE:
+ {
+ auto leaveEvent = std::make_shared<MouseLeaveEvent>();
+ leaveEvent->x = native->last_mouse_position.first;
+ leaveEvent->y = native->last_mouse_position.second;
+ native->event_queue.push_back(leaveEvent);
+ native->mouse_in_window = false;
+ }
+ break;
}
return DefWindowProc(hwnd, msg, wp, lp);
@@ -391,6 +421,9 @@ NativeWindowWin32::NativeWindowWin32(void* native_window, Window& window)
GetModuleHandle(nullptr), nullptr);
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
+
+ // Set up initial tracking of the mouse leave events
+ trackMouse(m_hwnd);
}
NativeWindowWin32::~NativeWindowWin32()