при нажатии на кнопку

Citrys

Участник
Автор темы
175
5
Версия MoonLoader
Другое

как сделать так, что при нажатии на кнопку (imui.Button()) появлялся текст​

 

barjik

Известный
464
190
Lua:
local imgui = require 'imgui'
local main_window_state = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('aye', cmd_aye)
        while true do
      wait(0)
      
if main_window_state.v == false then
    imgui.Process = false
    end
  end
end

function cmd_aye(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function imgui.OnDrawFrame()
    local ex, ey = getScreenResolution()
       imgui.SetNextWindowSize(imgui.ImVec2(767, 200), imgui.Cond.FirstUseEver)
       imgui.SetNextWindowPos(imgui.ImVec2(ex / 2, ey / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.Begin('Imgui window', main_window_state) -- начало окна
     if imgui.Button('click') then -- кнопка
     sampAddChatMessage('click!', -1) -- функция кнопки
     end
    imgui.End() -- конец
end
 

Citrys

Участник
Автор темы
175
5
Lua:
local imgui = require 'imgui'
local main_window_state = imgui.ImBool(false)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('aye', cmd_aye)
        while true do
      wait(0)
     
if main_window_state.v == false then
    imgui.Process = false
    end
  end
end

function cmd_aye(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function imgui.OnDrawFrame()
    local ex, ey = getScreenResolution()
       imgui.SetNextWindowSize(imgui.ImVec2(767, 200), imgui.Cond.FirstUseEver)
       imgui.SetNextWindowPos(imgui.ImVec2(ex / 2, ey / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.Begin('Imgui window', main_window_state) -- начало окна
     if imgui.Button('click') then -- кнопка
     sampAddChatMessage('click!', -1) -- функция кнопки
     end
    imgui.End() -- конец
end
не в чат, а в сомой Imgui