mirror of https://github.com/AxioDL/boo.git
Implement Mouse Enter/Leave Events
This commit is contained in:
parent
9fc3810015
commit
0f057a3713
|
@ -234,7 +234,8 @@ public:
|
|||
case WM_DEVICECHANGE:
|
||||
return DeviceFinder::winDevChangedHandler(wParam, lParam);
|
||||
|
||||
case WM_SIZE:
|
||||
case WM_SIZING:
|
||||
case WM_MOVING:
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYUP:
|
||||
|
@ -248,6 +249,10 @@ public:
|
|||
case WM_XBUTTONDOWN:
|
||||
case WM_XBUTTONUP:
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_MOUSELEAVE:
|
||||
case WM_NCMOUSELEAVE:
|
||||
case WM_MOUSEHOVER:
|
||||
case WM_NCMOUSEHOVER:
|
||||
window->_incomingEvent(&HWNDEvent(uMsg, wParam, lParam));
|
||||
|
||||
default:
|
||||
|
|
|
@ -486,8 +486,12 @@ public:
|
|||
{
|
||||
RECT rct;
|
||||
GetClientRect(m_hwnd, &rct);
|
||||
xOut = rct.left;
|
||||
yOut = rct.top;
|
||||
POINT pt;
|
||||
pt.x = rct.left;
|
||||
pt.y = rct.top;
|
||||
MapWindowPoints(m_hwnd, HWND_DESKTOP, &pt, 1);
|
||||
xOut = pt.x;
|
||||
yOut = pt.y;
|
||||
wOut = rct.right;
|
||||
hOut = rct.bottom;
|
||||
}
|
||||
|
@ -496,8 +500,12 @@ public:
|
|||
{
|
||||
RECT rct;
|
||||
GetClientRect(m_hwnd, &rct);
|
||||
xOut = rct.left;
|
||||
yOut = rct.top;
|
||||
POINT pt;
|
||||
pt.x = rct.left;
|
||||
pt.y = rct.top;
|
||||
MapWindowPoints(m_hwnd, HWND_DESKTOP, &pt, 1);
|
||||
xOut = pt.x;
|
||||
yOut = pt.y;
|
||||
wOut = rct.right;
|
||||
hOut = rct.bottom;
|
||||
}
|
||||
|
@ -571,12 +579,25 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void _trackMouse()
|
||||
{
|
||||
TRACKMOUSEEVENT tme;
|
||||
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
||||
tme.dwFlags = TME_NONCLIENT | TME_HOVER | TME_LEAVE;
|
||||
tme.dwHoverTime = 500;
|
||||
tme.hwndTrack = m_hwnd;
|
||||
}
|
||||
|
||||
bool mouseTracking = false;
|
||||
bool moving = false;
|
||||
bool resizing = false;
|
||||
|
||||
void _incomingEvent(void* ev)
|
||||
{
|
||||
HWNDEvent& e = *static_cast<HWNDEvent*>(ev);
|
||||
switch (e.uMsg)
|
||||
{
|
||||
case WM_SIZE:
|
||||
case WM_SIZING:
|
||||
{
|
||||
SWindowRect rect;
|
||||
getWindowFrame(rect.location[0], rect.location[1], rect.size[0], rect.size[1]);
|
||||
|
@ -587,6 +608,17 @@ public:
|
|||
m_callback->resized(rect);
|
||||
return;
|
||||
}
|
||||
case WM_MOVING:
|
||||
{
|
||||
SWindowRect rect;
|
||||
getWindowFrame(rect.location[0], rect.location[1], rect.size[0], rect.size[1]);
|
||||
if (!rect.size[0] || !rect.size[1])
|
||||
return;
|
||||
|
||||
if (m_callback)
|
||||
m_callback->windowMoved(rect);
|
||||
return;
|
||||
}
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
{
|
||||
|
@ -681,8 +713,51 @@ public:
|
|||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam)},
|
||||
{float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h)}
|
||||
};
|
||||
if (!mouseTracking)
|
||||
{
|
||||
_trackMouse();
|
||||
mouseTracking = true;
|
||||
m_callback->mouseEnter(coord);
|
||||
}
|
||||
else
|
||||
m_callback->mouseMove(coord);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
case WM_MOUSELEAVE:
|
||||
case WM_NCMOUSELEAVE:
|
||||
{
|
||||
if (m_callback)
|
||||
{
|
||||
int x, y, w, h;
|
||||
getWindowFrame(x, y, w, h);
|
||||
SWindowCoord coord =
|
||||
{
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h) }
|
||||
};
|
||||
m_callback->mouseLeave(coord);
|
||||
mouseTracking = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case WM_NCMOUSEHOVER:
|
||||
case WM_MOUSEHOVER:
|
||||
{
|
||||
if (m_callback)
|
||||
{
|
||||
int x, y, w, h;
|
||||
getWindowFrame(x, y, w, h);
|
||||
SWindowCoord coord =
|
||||
{
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h) }
|
||||
};
|
||||
m_callback->mouseEnter(coord);
|
||||
}
|
||||
return;
|
||||
}
|
||||
default: break;
|
||||
|
|
Loading…
Reference in New Issue