Skip to content

Commit

Permalink
feat(usability): Add ability to move while holding right mouse button
Browse files Browse the repository at this point in the history
  • Loading branch information
jag3dagster committed Jan 14, 2024
1 parent 501ac9b commit a679e17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/nui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
---
Expand Down
12 changes: 12 additions & 0 deletions web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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(
<React.StrictMode>
<MantineProvider withNormalizeCSS theme={customTheme}>
Expand Down

0 comments on commit a679e17

Please sign in to comment.