Skip to content

Commit

Permalink
fix: make ui focused while runcode is open
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanzaida committed Aug 23, 2024
1 parent f2263b8 commit 33b711d
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions code/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,15 @@ const commandName = 'toggleEditor';

const noop = (): void => null;

let tick = null;

const openEditor = (): void => {
SetNuiFocus(true, true);
SetNuiFocusKeepInput(true);
SetPlayerControl(PlayerId(), false, 0);
emitNUI('editor:isOpen', true);
tick = setTick(() => {
DisableAllControlActions(0);
});
SetNuiFocus(true, true);
};

const closeEditor = (): void => {
SetNuiFocus(false, false);
SetPlayerControl(PlayerId(), true, 0);
emitNUI('editor:isOpen', false);
clearTick(tick);
tick = undefined;
SetNuiFocus(false, false);
};

let isOpen = false;
Expand All @@ -45,6 +36,7 @@ onNUI('bcl-runcode:close', () => {
onNUI('bcl-runcode::run::js::server', (...args: unknown[]) => emitNet('bcl-code:runCode::js::server', ...args));

const gameName = GetGameName();

if (gameName === 'fivem') {
RegisterCommand('+' + commandName, noop, false);
RegisterCommand('-' + commandName, toggleEditor, false);
Expand Down

0 comments on commit 33b711d

Please sign in to comment.