From 27a8f8f18b1acb235ff2b17daf3e934344876219 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Sun, 28 May 2023 01:04:49 +0530 Subject: [PATCH] scrolling for touchpad fix --- .../Contents/Entitlements.plist | 4 ++++ src/MarbleGame.hx | 8 +++++++- src/gui/GuiControl.hx | 1 + src/gui/GuiScrollCtrl.hx | 4 ++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/macos-dist/MarbleBlast Platinum.app.in/Contents/Entitlements.plist b/macos-dist/MarbleBlast Platinum.app.in/Contents/Entitlements.plist index e89b7f32..6a6864e0 100644 --- a/macos-dist/MarbleBlast Platinum.app.in/Contents/Entitlements.plist +++ b/macos-dist/MarbleBlast Platinum.app.in/Contents/Entitlements.plist @@ -4,5 +4,9 @@ com.apple.security.app-sandbox + com.apple.security.network.client + + com.apple.security.network.server + diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 44ef49b2..824b4868 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -49,6 +49,8 @@ class MarbleGame { var consoleShown:Bool = false; var console:ConsoleDlg; + var _mouseWheelDelta:Float; + public function new(scene2d:h2d.Scene, scene:h3d.scene.Scene) { Console.log("Initializing the game..."); canvas = new Canvas(scene2d, cast this); @@ -169,6 +171,9 @@ class MarbleGame { Window.getInstance().removeEventTarget(@:privateAccess Key.onEvent); #end + scene2d.addEventListener(e -> { + _mouseWheelDelta = e.wheelDelta; + }); } public function update(dt:Float) { @@ -207,7 +212,8 @@ class MarbleGame { } var mouseState:MouseState = { - position: new Vector(canvas.scene2d.mouseX, canvas.scene2d.mouseY) + position: new Vector(canvas.scene2d.mouseX, canvas.scene2d.mouseY), + wheel: _mouseWheelDelta } ProfilerUI.measure("canvasUpdate"); canvas.update(dt, mouseState); diff --git a/src/gui/GuiControl.hx b/src/gui/GuiControl.hx index bdc07ab2..facb8a20 100644 --- a/src/gui/GuiControl.hx +++ b/src/gui/GuiControl.hx @@ -33,6 +33,7 @@ enum VertSizing { typedef MouseState = { var position:Vector; var ?button:Int; + var ?wheel:Float; } @:publicFields diff --git a/src/gui/GuiScrollCtrl.hx b/src/gui/GuiScrollCtrl.hx index 864da1fc..7828fd54 100644 --- a/src/gui/GuiScrollCtrl.hx +++ b/src/gui/GuiScrollCtrl.hx @@ -242,14 +242,14 @@ class GuiScrollCtrl extends GuiControl { } public override function update(dt:Float, mouseState:MouseState) { - if (Key.isPressed(Key.MOUSE_WHEEL_DOWN)) { + if (Key.isPressed(Key.MOUSE_WHEEL_DOWN) && Math.abs(mouseState.wheel) >= 1) { var renderRect = this.getRenderRectangle(); var scrollBarYSize = renderRect.extent.y * renderRect.extent.y / (maxScrollY * Settings.uiScale); this.scrollY += scrollBarYSize / 10; deltaY = scrollBarYSize / 10; this.updateScrollVisual(); } - if (Key.isPressed(Key.MOUSE_WHEEL_UP)) { + if (Key.isPressed(Key.MOUSE_WHEEL_UP) && Math.abs(mouseState.wheel) >= 1) { var renderRect = this.getRenderRectangle(); var scrollBarYSize = renderRect.extent.y * renderRect.extent.y / (maxScrollY * Settings.uiScale); this.scrollY -= scrollBarYSize / 10;