From ba50a90e200d189012289e56efa0865468ac4a08 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 21 Mar 2022 23:55:35 -0500 Subject: [PATCH] Allow mouse wheel for chat history scroll --- scripts/client/chatbox.js | 15 +++++++++++++++ scripts/client/event.js | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/scripts/client/chatbox.js b/scripts/client/chatbox.js index 28408a28..46813eee 100644 --- a/scripts/client/chatbox.js +++ b/scripts/client/chatbox.js @@ -107,4 +107,19 @@ function updateChatBox() { } } +// =========================================================================== + +function processMouseWheelForChatBox(up) { + // There isn't a way to detect whether chat input is active, but mouse cursor is forced shown when typing so ¯\_(ツ)_/¯ + if(!gui.cursorEnabled) { + return false; + } + + if(up) { + chatBoxScrollUp(); + } else { + chatBoxScrollDown() + } +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/client/event.js b/scripts/client/event.js index 91d1e502..760d08b8 100644 --- a/scripts/client/event.js +++ b/scripts/client/event.js @@ -51,6 +51,8 @@ function addAllEventHandlers() { addEventHandler("OnFocus", onFocus); addEventHandler("OnCameraProcess", onCameraProcess); + + addEventHandler("OnMouseWheel", onMouseWheel); } // =========================================================================== @@ -231,4 +233,22 @@ function onChatOutput(event, messageText, colour) { //receiveChatBoxMessageFromServer(messageText, colour); } +// =========================================================================== + +function onMouseWheel(event, mouseId, deltaCoordinates, flipped) { + if(!flipped) { + if(deltaCoordinates.y > 0) { + processMouseWheelForChatBox(true); + } else { + processMouseWheelForChatBox(false); + } + } else { + if(deltaCoordinates.y > 0) { + processMouseWheelForChatBox(false); + } else { + processMouseWheelForChatBox(true); + } + } +} + // =========================================================================== \ No newline at end of file