mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
scrolling for touchpad fix
This commit is contained in:
parent
e058f28865
commit
27a8f8f18b
4 changed files with 14 additions and 3 deletions
|
|
@ -4,5 +4,9 @@
|
|||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<false/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ enum VertSizing {
|
|||
typedef MouseState = {
|
||||
var position:Vector;
|
||||
var ?button:Int;
|
||||
var ?wheel:Float;
|
||||
}
|
||||
|
||||
@:publicFields
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue