# Module `ExpGamingCore.Gui.Inputs`

Adds a clean way of making new inputs for a gui allowing for sliders and text inputs to be hanndleded with custom events

### Info:

- License: https://github.com/explosivegaming/scenario/blob/master/LICENSE
- Author: Cooldude2606

## Functions

_comment () | This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module
inputs._input:on_event (event, callback) | Sets the input to trigger on an certain event
inputs._input:draw (root) | Draw the input into the root element
add (obj) | Add a new input, this is the same as doing frame.add{} but returns a diffrent object
add_elem_button (name, elem_type, tooltip, callback) | Used to define a choose-elem-button callback only on elem_changed
add_checkbox (name, radio, display, default, callback_true, callback_false) | Used to define a checkbox callback only on state_changed
reset_radio (elements) | Used to reset the state of radio buttons, recomened to be called on_state_change to reset any radio buttons it is ment to work with.
add_text (name, box, text, callback) | Used to define a text callback only on text_changed
add_slider (name, orientation, min, max, start_callback, callback) | Used to define a slider callback only on value_changed
add_drop_down (name, items, index, callback) | Used to define a drop down callback only on value_changed

## Functions

_comment ()
  This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module
inputs._input:on_event (event, callback)
  Sets the input to trigger on an certain event

  ### Parameters:

  - event the event to raise callback on | can be number of the event | can be a key of inputs.events
  - callback function the function you want to run on the event

  ### Returns:

  table returns self so you can chain together

  ### Usage:

      button:on_event(defines.events.on_gui_click,player_return)

inputs._input:draw (root)
  Draw the input into the root element

  ### Parameters:

  - root the element you want to add the input to

  ### Returns:

  returns the element that was added

  ### Usage:

      button:draw(frame)

add (obj)
  Add a new input, this is the same as doing frame.add{} but returns a diffrent object

  ### Parameters:

  - obj table the new element to add if caption is a sprite path then sprite is used

  ### Returns:

  table the custom input object

  ### Usage:

      Gui.inputs.add{type='button',name='test',caption='Test'}

add_elem_button (name, elem_type, tooltip, callback)
  Used to define a choose-elem-button callback only on elem_changed

  ### Parameters:

  - name string the name of this button
  - elem_type string the display for this button, either text or sprite path
  - tooltip string the tooltip to show on the button
  - callback function the callback to call on change function(player,element,elem)

  ### Returns:

  table the button object that was made, to allow a custom error event if wanted

  ### Usage:

      Gui.inputs.add_elem_button('test','Test','Just for testing',function)

add_checkbox (name, radio, display, default, callback_true, callback_false)
  Used to define a checkbox callback only on state_changed

  ### Parameters:

  - name string the name of this button
  - radio boolean if this is a radio button
  - display string the display for this button, either text or sprite path
  - default function the callback which choses the default check state
  - callback_true function the callback to call when changed to true
  - callback_false function the callback to call when changed to false

  ### Returns:

  table the button object that was made, to allow a custom error event if wanted

  ### Usage:

      Gui.inputs.add_checkbox('test',false,'Just for testing',function,function,funvtion)

reset_radio (elements)
  Used to reset the state of radio buttons, recomened to be called on_state_change to reset any radio buttons it is ment to work with.

  ### Parameters:

  - elements can be a list of elements or a single element

  ### Usage:

      Gui.inputs.reset_radio{radio1,radio2,...}

add_text (name, box, text, callback)
  Used to define a text callback only on text_changed

  ### Parameters:

  - name string the name of this button
  - box boolean is it a text box rather than a text field
  - text string the starting text
  - callback function the callback to call on change function(player,text,element)

  ### Returns:

  table the text object that was made, to allow a custom error event if wanted

  ### Usage:

      Gui.inputs.add_text('test',false,'Just for testing',function)

add_slider (name, orientation, min, max, start_callback, callback)
  Used to define a slider callback only on value_changed

  ### Parameters:

  - name string the name of this button
  - orientation string direction of the slider
  - min number the lowest number
  - max number the highest number
  - start_callback function either a number or a function to return a number
  - callback function the function to be called on value_changed function(player,value,percent,element)

  ### Returns:

  table the slider object that was made, to allow a custom error event if wanted

  ### Usage:

      Gui.inputs.add_slider('test','horizontal',1,10,5,function)

add_drop_down (name, items, index, callback)
  Used to define a drop down callback only on value_changed

  ### Parameters:

  - name string name of the drop down
  - items either a list or a function which returns a list
  - index either a number or a function which returns a number
  - callback function the callback which is called when a new index is selected function(player,selected,items,element)

  ### Returns:

  table the drop-down object that was made, to allow a custom error event if wanted

  ### Usage:

      Gui.inputs.add_drop_down('test',{1,2,3},1,function)

generated by LDoc 1.4.6 Last updated 2018-06-07 12:58:23