mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 21:01:39 +09:00
Addded Text Inputs
This commit is contained in:
@@ -233,6 +233,33 @@ function inputs.reset_radio(elements)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Used to define a text callback only on text_changed
|
||||||
|
-- @usage Gui.inputs.add_text('test',false,'Just for testing',function)
|
||||||
|
-- @tparam string name the name of this button
|
||||||
|
-- @tparam boolean box is it a text box rather than a text field
|
||||||
|
-- @tparam string text the starting text
|
||||||
|
-- @tparam function the callback to call on change function(player,text,element)
|
||||||
|
-- @treturn table the text object that was made, to allow a custom error event if wanted
|
||||||
|
function inputs.add_text(name,box,text,callback)
|
||||||
|
local type = 'textfield'; if box then type='text-box' end
|
||||||
|
local textbox = inputs.add{
|
||||||
|
type=type,
|
||||||
|
name=name,
|
||||||
|
text=text
|
||||||
|
}
|
||||||
|
textbox.data._callback = callback
|
||||||
|
textbox:on_event('text',function(event)
|
||||||
|
local player = Game.get_player(event)
|
||||||
|
local element = event.element
|
||||||
|
local callback = textbox.data._callback
|
||||||
|
if is_type(callback,'function') then
|
||||||
|
local success, err = pcall(callback,player,element.text,element)
|
||||||
|
if not success then error(err) end
|
||||||
|
else error('Invalid Callback Condition Format') end
|
||||||
|
end)
|
||||||
|
return textbox
|
||||||
|
end
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
--[[
|
--[[
|
||||||
|
|
||||||
|
|||||||
@@ -102,3 +102,11 @@ radio_test = Gui.inputs.add_checkbox('test-radio',true,'Kill Self',function(pare
|
|||||||
end,function(player,element)
|
end,function(player,element)
|
||||||
if player.character then player.character.die() end
|
if player.character then player.character.die() end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
text_test = Gui.inputs.add_text('test-text',false,'default text',function(player,text,element)
|
||||||
|
player_return(text,nil,player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
box_test = Gui.inputs.add_text('test-box',true,'default text but a box',function(player,text,element)
|
||||||
|
player_return(text,nil,player)
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user