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

View file

@ -531,11 +531,13 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_XBUTTONDOWN:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_XBUTTONUP:
case WM_MOUSEWHEEL:
case WM_MOUSEMOVE:
{
@ -603,6 +605,9 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_MBUTTONDOWN:
_BtnDown(2);
break;
case WM_XBUTTONDOWN:
_BtnDown((int)(wParam >> 16) + 2);
break;
case WM_LBUTTONUP:
_BtnUp(0);
break;
@ -612,6 +617,9 @@ LRESULT WinBFWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_MBUTTONUP:
_BtnUp(2);
break;
case WM_XBUTTONUP:
_BtnUp((int)(wParam >> 16) + 2);
break;
case WM_MOUSEWHEEL:
{
WinBFWindow* cursorWindow = this;

View file

@ -5308,6 +5308,7 @@ namespace IDE
public void SetupNewWindow(WidgetWindow window, bool isMainWindow)
{
window.mOnWindowKeyDown.Add(new => SysKeyDown);
window.mOnMouseUp.Add(new => MouseUp);
if (isMainWindow)
window.mOnWindowCloseQuery.Add(new => SecondaryAllowClose);
}
@ -7087,6 +7088,14 @@ namespace IDE
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)
{
if (evt.mHandled)
@ -10996,6 +11005,7 @@ namespace IDE
UpdateTitle();
mMainWindow.SetMinimumSize(GS!(480), GS!(360));
mMainWindow.mIsMainWindow = true;
mMainWindow.mOnMouseUp.Add(new => MouseUp);
mMainWindow.mOnWindowKeyDown.Add(new => SysKeyDown);
mMainWindow.mOnWindowCloseQuery.Add(new => AllowClose);
CreateMenu();