mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
fix - ehm something,
This commit is contained in:
@@ -0,0 +1 @@
|
||||
PREVIEW_KEYBIND = false -- "LMENU"
|
||||
@@ -11,6 +11,7 @@ ui_page 'index.html'
|
||||
shared_script '@es_extended/imports.lua'
|
||||
|
||||
client_scripts {
|
||||
'config.lua',
|
||||
'main.lua',
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user