diff --git a/client/nui.lua b/client/nui.lua index 5ce1a06..9a178b9 100644 --- a/client/nui.lua +++ b/client/nui.lua @@ -49,6 +49,11 @@ RegisterNUICallback('ht_mlotool:fetchLocales', function(_, cb) cb(locales) end) +RegisterNUICallback('ht_mlotool:freeMove', function(enabled, cb) + cb({}) + SetNuiFocusKeepInput(enabled) +end) + --- A simple wrapper around SendNUIMessage that you can use to --- dispatch actions to the React frame. --- diff --git a/web/src/main.tsx b/web/src/main.tsx index ba673da..5e6d70e 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -6,6 +6,7 @@ import App from "./App"; import "./index.css"; import { customTheme } from "./theme"; import { debugData } from "./utils/debugData"; +import { fetchNui } from "./utils/fetchNui"; import { isEnvBrowser } from "./utils/misc"; debugData([ @@ -200,6 +201,17 @@ if (isEnvBrowser()) { const reactRoot = ReactDOM.createRoot(root!); +// Enable freemove while holding down right mouse button +{ + root!.addEventListener("mousedown", (e) => { + if (e.button === 2) fetchNui("ht_mlotool:freeMove", true, "1"); + }); + + root!.addEventListener("mouseup", (e) => { + if (e.button === 2) fetchNui("ht_mlotool:freeMove", false, "1"); + }); +} + reactRoot.render(