addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY)
if button == "left" and state == "down" then
if isRendering and isCursorShowing() then
local panelX, panelY, buttonHeight, sidebarWidth, screenScale = createWindow()
for i, buttonData in ipairs(settingsTitles) do
local buttonX = panelX + 4
local buttonY = panelY + (i - 1) * (buttonHeight + 2)
local buttonWidth = sidebarWidth - 8
local buttonHeight = 50 * screenScale
if absoluteX >= buttonX and absoluteX <= buttonX + buttonWidth and absoluteY >= buttonY and absoluteY <= buttonY + buttonHeight then
activeButton = i
end
end
elseif not isCursorShowing() then
local panelX, panelY, buttonHeight, sidebarWidth, screenScale = createWindow()
end
end
end)
function handleButtonCloseWindow(button, state, absoluteX, absoluteY)
if button == "left" and state == "down" then
local _ , _ , _ , _ , _ , closeButtonWidth, closeButtonHeight, closeButtonX, closeButtonY = createWindow()
if absoluteX >= closeButtonX and absoluteX <= closeButtonX + closeButtonWidth and absoluteY >= closeButtonY and absoluteY <= closeButtonY + closeButtonHeight then
isRendering = false
showCursor(false)
removeEventHandler("onClientRender", root, createWindow)
end
end
end
addEventHandler("onClientClick", root, handleButtonCloseWindow)
local function addBindKey()
isRendering = not isRendering
if (isRendering) then
addEventHandler("onClientRender", root, createWindow)
showCursor(true)
else
showCursor(false)
removeEventHandler("onClientRender", root, createWindow)
end
end
bindKey("F1", "down", addBindKey)