Gui module

Makes monolithic Factorio GUI events more manageable.

Usage

local Gui = require('stdlib/event/gui')

Functions

dispatch (event) Calls the registered handlers.
on_checked_state_changed (gui_element_pattern, handler) Registers a function for a given GUI element name or pattern when the element checked state changes.
on_click (gui_element_pattern, handler) Registers a function for a given gui element name or pattern when the element is clicked.
on_elem_changed (gui_element_pattern, handler) Registers a function for a given GUI element name or pattern when the element selection changes.
on_selection_state_changed (gui_element_pattern, handler) Registers a function for a given GUI element name or pattern when the element state changes (dropdown).
on_text_changed (gui_element_pattern, handler) Registers a function for a given GUI element name or pattern when the element text changes.
register (event_id, gui_element_pattern, handler) Registers a function for a given event and matching gui element pattern.
remove (event_id, gui_element_pattern) Removes the handler with matching gui element pattern from the event.

Functions

# dispatch (event)

Calls the registered handlers.

Parameters:
# on_checked_state_changed (gui_element_pattern, handler)

Registers a function for a given GUI element name or pattern when the element checked state changes.

Parameters:
  • gui_element_pattern : (string) the name or string regular expression to match the GUI element
  • handler : (function) the function to call when GUI element checked state changes
Returns:
# on_click (gui_element_pattern, handler)

Registers a function for a given gui element name or pattern when the element is clicked.

Parameters:
  • gui_element_pattern : (string) the name or string regular expression to match the gui element
  • handler : (function) the function to call when gui element is clicked
Returns:
# on_elem_changed (gui_element_pattern, handler)

Registers a function for a given GUI element name or pattern when the element selection changes.

Parameters:
  • gui_element_pattern : (string) the name or string regular expression to match the GUI element
  • handler : (function) the function to call when GUI element selection changes
Returns:
# on_selection_state_changed (gui_element_pattern, handler)

Registers a function for a given GUI element name or pattern when the element state changes (dropdown).

Parameters:
  • gui_element_pattern : (string) the name or string regular expression to match the GUI element
  • handler : (function) the function to call when GUI element state changes
Returns:
# on_text_changed (gui_element_pattern, handler)

Registers a function for a given GUI element name or pattern when the element text changes.

Parameters:
  • gui_element_pattern : (string) the name or string regular expression to match the GUI element
  • handler : (function) the function to call when GUI element text changes
Returns:
# register (event_id, gui_element_pattern, handler)

Registers a function for a given event and matching gui element pattern.

Parameters:
  • event_id : (defines.events) valid values are defines.events.on_gui_* from defines.events
  • gui_element_pattern : (string) the name or string regular expression to match the gui element
  • handler : (function) the function to call when the event is triggered
Returns:
# remove (event_id, gui_element_pattern)

Removes the handler with matching gui element pattern from the event.

Parameters:
  • event_id : (defines.events) valid values are defines.events.on_gui_* from defines.events
  • gui_element_pattern : (string) the name or string regular expression for a handler to remove
Returns: