From ecbd415218529948184a17a7bd486f42a74d4f2b Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Tue, 7 Mar 2023 21:41:34 +0000 Subject: [PATCH] Added invert menu scrolling script + optional setting --- invert-menu-scrolling/invertMenuScrolling.js | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 invert-menu-scrolling/invertMenuScrolling.js diff --git a/invert-menu-scrolling/invertMenuScrolling.js b/invert-menu-scrolling/invertMenuScrolling.js new file mode 100644 index 0000000..5db9352 --- /dev/null +++ b/invert-menu-scrolling/invertMenuScrolling.js @@ -0,0 +1,40 @@ +import { app } from "/scripts/app.js"; + +// Inverts the scrolling of context menus so down scrolls down! + +const ctxMenu = LiteGraph.ContextMenu; +app.registerExtension({ + name: "pysssss.InvertMenuScrolling", + init() { + const replace = () => { + LiteGraph.ContextMenu = function (values, options) { + options = options || {}; + if (options.scroll_speed) { + options.scroll_speed *= -1; + } else { + options.scroll_speed = -0.1; + } + return ctxMenu.call(this, values, options); + }; + LiteGraph.ContextMenu.prototype = ctxMenu.prototype; + }; + // If the UI has setting support then add a setting, else just enable it + if (app.ui.settings) { + app.ui.settings.addSetting({ + id: "pysssss.InvertMenuScrolling", + name: "Invert Menu Scrolling", + type: "boolean", + defaultValue: true, + onChange(value) { + if (value) { + replace(); + } else { + LiteGraph.ContextMenu = ctxMenu; + } + }, + }); + } else { + replace(); + } + }, +});