mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-12-21 03:17:11 +01:00
Version 0.999 BETA - a lot of bug fixes, improvments and more advanced bot
This commit is contained in:
56
modules/game_textedit/textedit.lua
Normal file
56
modules/game_textedit/textedit.lua
Normal file
@@ -0,0 +1,56 @@
|
||||
local activeWindow
|
||||
|
||||
function init()
|
||||
g_ui.importStyle('textedit')
|
||||
|
||||
connect(g_game, { onGameEnd = destroyWindow })
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onGameEnd = destroyWindow })
|
||||
|
||||
destroyWindow()
|
||||
end
|
||||
|
||||
function destroyWindow()
|
||||
if activeWindow then
|
||||
activeWindow:destroy()
|
||||
activeWindow = nil
|
||||
end
|
||||
end
|
||||
|
||||
function show(widget)
|
||||
if not widget then
|
||||
return
|
||||
end
|
||||
if activeWindow then
|
||||
destroyWindow()
|
||||
end
|
||||
local window = g_ui.createWidget('TextEditWindow', rootWidget)
|
||||
|
||||
local destroy = function()
|
||||
window:destroy()
|
||||
if window == activeWindow then
|
||||
activeWindow = nil
|
||||
end
|
||||
end
|
||||
local doneFunc = function()
|
||||
widget:setText(window.text:getText())
|
||||
destroy()
|
||||
end
|
||||
|
||||
window.okButton.onClick = doneFunc
|
||||
window.cancelButton.onClick = destroy
|
||||
window.onEnter = doneFunc
|
||||
window.onEscape = destroy
|
||||
|
||||
window.text:setText(widget:getText())
|
||||
|
||||
activeWindow = window
|
||||
activeWindow:raise()
|
||||
activeWindow:focus()
|
||||
end
|
||||
|
||||
function hide()
|
||||
destroyWindow()
|
||||
end
|
||||
Reference in New Issue
Block a user