1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-15 06:44:10 +02:00

Support for Forward/Backward mouse buttons

This commit is contained in:
Brian Fiete 2020-09-03 08:14:24 -07:00
parent 37f73f3345
commit 0347f997f2
3 changed files with 48 additions and 4 deletions

View file

@ -23,6 +23,7 @@ namespace Beefy.widgets
public Event<MouseLeftWindowHandler> mOnMouseLeftWindow ~ _.Dispose(); public Event<MouseLeftWindowHandler> mOnMouseLeftWindow ~ _.Dispose();
public Event<WindowLostFocusHandler> mOnWindowLostFocus ~ _.Dispose(); public Event<WindowLostFocusHandler> mOnWindowLostFocus ~ _.Dispose();
public Event<MouseEventHandler> mOnMouseDown ~ _.Dispose(); public Event<MouseEventHandler> mOnMouseDown ~ _.Dispose();
public Event<MouseEventHandler> mOnMouseUp ~ _.Dispose();
public Event<WindowCloseQueryHandler> mOnWindowCloseQuery ~ _.Dispose(); public Event<WindowCloseQueryHandler> mOnWindowCloseQuery ~ _.Dispose();
public Event<WindowClosedHandler> mOnWindowClosed ~ _.Dispose(); public Event<WindowClosedHandler> mOnWindowClosed ~ _.Dispose();
public Event<WindowMovedHandler> mOnWindowMoved ~ _.Dispose(); public Event<WindowMovedHandler> mOnWindowMoved ~ _.Dispose();
@ -653,12 +654,17 @@ namespace Beefy.widgets
anEvent.mSender = this; anEvent.mSender = this;
anEvent.mX = x; anEvent.mX = x;
anEvent.mY = y; anEvent.mY = y;
anEvent.mBtn = btn;
anEvent.mBtnCount = btnCount;
mOnMouseDown(anEvent); mOnMouseDown(anEvent);
sOnMouseDown(anEvent); sOnMouseDown(anEvent);
if (anEvent.mHandled) if (anEvent.mHandled)
return; return;
} }
if (btn >= 3) // X button - don't pass on to widgets
return;
Widget aWidget = mCaptureWidget ?? mOverWidget; Widget aWidget = mCaptureWidget ?? mOverWidget;
if (aWidget != null) if (aWidget != null)
{ {
@ -679,6 +685,26 @@ namespace Beefy.widgets
MouseMove(inX, inY); MouseMove(inX, inY);
mMouseFlags &= (MouseFlag)(~(1 << btn)); mMouseFlags &= (MouseFlag)(~(1 << btn));
float x;
float y;
TranslateMouseCoords(inX, inY, out x, out y);
if (mOnMouseUp.HasListeners)
{
MouseEvent anEvent = scope MouseEvent();
anEvent.mSender = this;
anEvent.mX = x;
anEvent.mY = y;
anEvent.mBtn = btn;
mOnMouseUp(anEvent);
if (anEvent.mHandled)
return;
}
if (btn >= 3) // X button - don't pass on to widgets
return;
Widget aWidget = mCaptureWidget ?? mOverWidget; Widget aWidget = mCaptureWidget ?? mOverWidget;
if (aWidget != null) if (aWidget != null)
{ {

View file

@ -531,13 +531,15 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
case WM_XBUTTONDOWN:
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_RBUTTONUP: case WM_RBUTTONUP:
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_XBUTTONUP:
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
int x = (short)LOWORD(lParam); int x = (short)LOWORD(lParam);
int y = (short)HIWORD(lParam); int y = (short)HIWORD(lParam);
@ -602,7 +604,10 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
_BtnDown(2); _BtnDown(2);
break; break;
case WM_XBUTTONDOWN:
_BtnDown((int)(wParam >> 16) + 2);
break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
_BtnUp(0); _BtnUp(0);
break; break;
@ -611,7 +616,10 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
case WM_MBUTTONUP: case WM_MBUTTONUP:
_BtnUp(2); _BtnUp(2);
break; break;
case WM_XBUTTONUP:
_BtnUp((int)(wParam >> 16) + 2);
break;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
{ {
WinBFWindow* cursorWindow = this; WinBFWindow* cursorWindow = this;

View file

@ -5308,6 +5308,7 @@ namespace IDE
public void SetupNewWindow(WidgetWindow window, bool isMainWindow) public void SetupNewWindow(WidgetWindow window, bool isMainWindow)
{ {
window.mOnWindowKeyDown.Add(new => SysKeyDown); window.mOnWindowKeyDown.Add(new => SysKeyDown);
window.mOnMouseUp.Add(new => MouseUp);
if (isMainWindow) if (isMainWindow)
window.mOnWindowCloseQuery.Add(new => SecondaryAllowClose); window.mOnWindowCloseQuery.Add(new => SecondaryAllowClose);
} }
@ -7087,6 +7088,14 @@ namespace IDE
gApp.mSettings.mUISettings.mScale = DarkTheme.sScale * 100.0f; gApp.mSettings.mUISettings.mScale = DarkTheme.sScale * 100.0f;
} }
void MouseUp(MouseEvent evt)
{
if (evt.mBtn == 3)
NavigateBackwards();
else if (evt.mBtn == 4)
NavigateForwards();
}
void SysKeyDown(KeyDownEvent evt) void SysKeyDown(KeyDownEvent evt)
{ {
if (evt.mHandled) if (evt.mHandled)
@ -10996,6 +11005,7 @@ namespace IDE
UpdateTitle(); UpdateTitle();
mMainWindow.SetMinimumSize(GS!(480), GS!(360)); mMainWindow.SetMinimumSize(GS!(480), GS!(360));
mMainWindow.mIsMainWindow = true; mMainWindow.mIsMainWindow = true;
mMainWindow.mOnMouseUp.Add(new => MouseUp);
mMainWindow.mOnWindowKeyDown.Add(new => SysKeyDown); mMainWindow.mOnWindowKeyDown.Add(new => SysKeyDown);
mMainWindow.mOnWindowCloseQuery.Add(new => AllowClose); mMainWindow.mOnWindowCloseQuery.Add(new => AllowClose);
CreateMenu(); CreateMenu();