fix - ehm something,

This commit is contained in:
Benzo
2022-08-02 16:23:32 +02:00
committed by GitHub
parent 785aac1a18
commit 3000eb8aa6
4 changed files with 78 additions and 48 deletions
+1
View File
@@ -0,0 +1 @@
PREVIEW_KEYBIND = false -- "LMENU"
+1
View File
@@ -11,6 +11,7 @@ ui_page 'index.html'
shared_script '@es_extended/imports.lua'
client_scripts {
'config.lua',
'main.lua',
}
+8 -3
View File
@@ -3,6 +3,7 @@
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -286,9 +287,13 @@
})
window.addEventListener("keydown",(e) => {
if (e.key == "Escape" || e.key == "Backspace") {
Close()
}
if (e.key == "Escape" || e.key == "Backspace") {
if (e.target.tagName.toLowerCase() == "input") {
return
}
Close()
}
})
// Open([
+68 -45
View File
@@ -20,6 +20,8 @@ function Open(position,eles,onSelect,onClose)
onClose = onClose
}
LocalPlayer.state:set("context:active",true)
Post("Open",eles,position)
end
@@ -31,6 +33,8 @@ function Closed()
activeMenu = nil
LocalPlayer.state:set("context:active",false)
if cb then
cb(menu)
end
@@ -95,7 +99,7 @@ RegisterNUICallback("selected",function(data)
return
end
activeMenu.onSelect(activeMenu,ele)
activeMenu:onSelect(ele)
end)
RegisterNUICallback("changed",function(data)
@@ -130,62 +134,81 @@ RegisterNUICallback("changed",function(data)
end
end)
-- Keybind
local function focusPreview()
if not activeMenu
or not activeMenu.onSelect
then
return
end
SetNuiFocus(true,true)
end
if PREVIEW_KEYBIND then
RegisterCommand("previewContext",focusPreview)
RegisterKeyMapping("previewContext","Preview Active Context","keyboard",PREVIEW_KEYBIND)
end
exports("focusPreview",focusPreview)
-- Debug/Test
-- Commands:
-- [ ctx:preview | ctx:open | ctx:close | ctx:form ]
local position = "right"
if Debug then
local position = "right"
local eles = {
{
unselectable=true,
icon="fas fa-info-circle",
title="Unselectable Item (Header/Label?)",
},
{
icon="fas fa-check",
title="Item A",
description="Some description here. Add some words to make the text overflow."
},
{
disabled=true,
icon="fas fa-times",
title="Disabled Item",
description="Some description here. Add some words to make the text overflow."
},
{
icon="fas fa-check",
title="Item B",
description="Some description here. Add some words to make the text overflow."
},
}
local eles = {
{
unselectable=true,
icon="fas fa-info-circle",
title="Unselectable Item (Header/Label?)",
},
{
icon="fas fa-check",
title="Item A",
description="Some description here. Add some words to make the text overflow."
},
{
disabled=true,
icon="fas fa-times",
title="Disabled Item",
description="Some description here. Add some words to make the text overflow."
},
{
icon="fas fa-check",
title="Item B",
description="Some description here. Add some words to make the text overflow."
},
}
local function onSelect(menu,ele)
print("Ele selected",ele.title)
local function onSelect(menu,ele)
print("Ele selected",ele.title)
if ele.name == "close" then
exports["esx_context"]:Close()
end
if ele.name ~= "submit" then
return
end
for _,ele in ipairs(menu.eles) do
if ele.input then
print(ele.name,ele.inputType,ele.inputValue)
end
end
if ele.name == "close" then
exports["esx_context"]:Close()
end
if ele.name ~= "submit" then
return
local function onClose(menu)
print("Menu closed.")
end
for _,ele in ipairs(menu.eles) do
if ele.input then
print(ele.name,ele.inputType,ele.inputValue)
end
end
exports["esx_context"]:Close()
end
local function onClose(menu)
print("Menu closed.")
end
if Debug then
RegisterCommand("ctx:preview",function()
exports["esx_context"]:Preview(position,eles)
end)