Module dispatcher

This module is responsible for dispatching events.

To add a new action an entry must be added to settingsList & dispatcher_menu_order This can also be done at runtime via registerAction().

settingsList contains the list of dispatchable settings.

Each setting contains:

  • category: one of:
    * none: a direct event call
    * arg: a event that expects a gesture object or an argument
    * absolutenumber: event that sets a number
    * incrementalnumber: event that increments a number & accepts a gesture object
    * string: event with a list of arguments to chose from
    * configurable: like string but instead of an event it updates the configurable (used by kopt)
    
  • event: what to call.
  • title: for use in ui.
  • section: under which menu to display (currently: general, device, screen, filemanager, reader, rolling, paging)
    and optionally
    
  • min/max: for number
  • step: for number
  • default
  • args: allowed values for string.
  • toggle: display name for args
  • separator: put a separator after in the menu list
  • configurable: can be parsed from cre/kopt and used to set document.configurable. Should not be set manually

Functions

Dispatcher:init () add settings from CreOptions / KoptOptions
Dispatcher:registerAction (name, value) Adds settings at runtime.
Dispatcher:removeAction (name) Removes settings at runtime.
Dispatcher:addSubMenu (caller, menu, location, settings)

Add a submenu to edit which items are dispatched arguments are:

1) the caller so dispatcher can set the updated flag
2) the table representing the submenu (can be empty)
3) the object (table) in which the settings table is found
4) the name of the settings table

example usage:

Dispatcher:addSubMenu(self, sub_items, self.data, "profile1")
Dispatcher:execute (settings, exec_props)

Calls the events in a settings list arguments are:

1) the settings table
2) execution management table: { qm_show = true|false} - forcibly show QM / run
                               { qm_anchor = ges.pos } - anchor position
                               { gesture = ges } - a <code>gestures</code> object


Functions

Dispatcher:init ()
add settings from CreOptions / KoptOptions
Dispatcher:registerAction (name, value)
Adds settings at runtime.

Parameters:

  • name the key to use in the table
  • value a table per settingsList above

Usage:

    function Hello:onDispatcherRegisterActions()
        Dispatcher:registerAction("helloworld_action", {category="none", event="HelloWorld", title=_("Hello World"), general=true})
    end
    
    function Hello:init()
        self:onDispatcherRegisterActions()
    end
Dispatcher:removeAction (name)
Removes settings at runtime.

Parameters:

  • name the key to use in the table
Dispatcher:addSubMenu (caller, menu, location, settings)

Add a submenu to edit which items are dispatched arguments are:

1) the caller so dispatcher can set the updated flag
2) the table representing the submenu (can be empty)
3) the object (table) in which the settings table is found
4) the name of the settings table

example usage:

Dispatcher:addSubMenu(self, sub_items, self.data, "profile1")

Parameters:

  • caller
  • menu
  • location
  • settings
Dispatcher:execute (settings, exec_props)

Calls the events in a settings list arguments are:

1) the settings table
2) execution management table: { qm_show = true|false} - forcibly show QM / run
                               { qm_anchor = ges.pos } - anchor position
                               { gesture = ges } - a <code>gestures</code> object

Parameters:

  • settings
  • exec_props
generated by LDoc 1.5.0 Last updated 2024-03-18 16:45:36