Module view.editor

Editor module

Class Editor

Editor:init () Editor constructor.
Editor:OnStartChange (name) Called when a field starts to change.
Editor:OnFieldChange (name, value) Called when a field value was modified Override.
Editor:IsValidState (name) Should return true if state is valid for this editor.
Editor:OnEnterState (name) Called when the state was entered.
Editor:OnLeaveState (name) Called when the state was left.
Editor:Finalize (children, opts) Called at the end of :init(), to finalize the UI Override.
Editor:SetInvisibleFields (...) Sets fields which are to be made invisible.
Editor:RemoveField (name) Remove field by name.
Editor:AddField (field) Add field.
Editor:Set (name, value) Set value of a field.
Editor:Serialize () Serialize editor fields into a table.
Editor:Load (tbl) Load table into fields.
Editor.Register (opts) Register editor globally.
Editor.Deregister (name) Deregister editor globally.


Class Editor

Editor class. Inherit to create custom Editors
Editor:init ()
Editor constructor. Make sure you invoke this in your custom editor

See also:

Usage:

     MyEditor = Editor:extends{}
     function MyEditor:init()
         Editor.init(self)
         -- rest of code
         self:Finalize(children, opts)
     end
Editor:OnStartChange (name)
Called when a field starts to change. Override.

Parameters:

  • name string Name of the field.
Editor:OnFieldChange (name, value)
Called when a field value was modified Override.

Parameters:

  • name string Name of the modified field.
  • value New value of the modified field.
Editor:IsValidState (name)
Should return true if state is valid for this editor. Override.

Parameters:

  • name state State.
Editor:OnEnterState (name)
Called when the state was entered. Override.

Parameters:

  • name state State.
Editor:OnLeaveState (name)
Called when the state was left. Override.

Parameters:

  • name state State.
Editor:Finalize (children, opts)
Called at the end of :init(), to finalize the UI Override.

Parameters:

  • children table List of Chili controls.
  • opts Editor options
    • notMainWindow boolean If true, editor will not be added to the main panel (right side), but will instead be a floating window. (default false)
    • width boolean Specifies window width. Only applicable for floating windows. (default 550)
    • height boolean Specifies window height. Only applicable for floating windows. (default 550)
    • noCloseButton boolean If true, there will be no close button. (default false)
    • disposeOnClose boolean If true, the window will be disposed when closed. Defaults to true if opts.notMainWindow is true, otherwise it defaults to false.
Editor:SetInvisibleFields (...)
Sets fields which are to be made invisible.

Parameters:

  • ... {string, } ... Field names to be set invisible
Editor:RemoveField (name)
Remove field by name.

Parameters:

  • name string Name of field which should be removed.
Editor:AddField (field)
Add field.

Parameters:

  • field field.Field Field to be added.

Usage:

     self:AddField(NumericField({
         name = "size",
         value = 100,
         minValue = 40,
         maxValue = 2000,
         title = "Size:",
         tooltip = "Size of the paint brush",
     }))
Editor:Set (name, value)
Set value of a field.

Parameters:

  • name string Field name.
  • value New value.

Usage:

    self:Set("myNumber", 15)
Editor:Serialize ()
Serialize editor fields into a table.

Returns:

    Serialized table of all fields.
Editor:Load (tbl)
Load table into fields.

Parameters:

  • tbl table Serialized table to load.
Editor.Register (opts)
Register editor globally.

Parameters:

  • opts Table
    • name string Machine name of the editor control.
    • editor Editor Class inheritng from Editor
    • tab string Tab in which to place the editor button.
    • caption string Title of the Editor control.
    • tooltip string Mouseover tooltip.
    • image string Path to the Editor icon.

Usage:

     GrassEditor = Editor:extends{}
     Editor.Register({
         name = "grassEditor",
         editor = GrassEditor,
         tab = "Map",
         caption = "Grass",
         tooltip = "Edit grass",
         image = SB.DIRS.IMG .. "grass.png",
         order = 4,
     })
Editor.Deregister (name)
Deregister editor globally.

Parameters:

  • name string Name of Editor to unregister
generated by LDoc 1.4.3 Last updated 2017-09-23 19:07:28