# Module `gui`

Use gui to define your script's custom graphical user interface.

Custom GUI example : sinemouse-demo.lua

The gui global is available to every protoplug script after including the main protoplug header :

    require "include/protoplug"

## Functions

gui.addHandler (event, handler) | Add a handler for a GUI event.
gui.paint (g) | Override to paint a custom GUI.
gui.getComponent () | Get GUI Component.

## Tables

gui.FocusCause | Focus change causes.
gui.ModifierKeys | Keyboard and mouse modifiers.

## Class gui.MouseEvent

gui.MouseEvent.x | X.
gui.MouseEvent.y | Y.
gui.MouseEvent.mods | Modifier keys.
gui.MouseEvent.eventComponent | Event component.
gui.MouseEvent.originalComponent | Original component.
gui.MouseEvent.eventTime | Time.
gui.MouseEvent.mouseDownTime | Mouse down time.
gui.MouseEvent.mouseDownPos | Mouse down position.
gui.MouseEvent.numberOfClicks | Number of clicks.
gui.MouseEvent.wasMovedSinceMouseDown | Was moved since mouse down.

## Class gui.MouseWheelDetails

gui.MouseWheelDetails.deltaX | X delta.
gui.MouseWheelDetails.deltaY | Y delta.
gui.MouseWheelDetails.isReversed | Is reversed.
gui.MouseWheelDetails.isSmooth | Is smooth.

## Class gui.KeyPress

gui.KeyPress.keyCode | Key code.
gui.KeyPress.mods | Modifier Keys.
gui.KeyPress.textCharacter | Text character.

## Functions

gui.addHandler (event, handler)
  Add a handler for a GUI event.

  Here's a list of the events and their parameters, showing how they should be received :

      gui.addHandler("resized",               function() ... end)
      gui.addHandler("focusGained",           function(focusCause) ... end)
      gui.addHandler("focusLost",             function(focusCause) ... end)
      gui.addHandler("modifierKeysChanged",   function(modifierKeys) ... end)
      gui.addHandler("mouseMove",             function(mouseEvent) ... end)
      gui.addHandler("mouseEnter",            function(mouseEvent) ... end)
      gui.addHandler("mouseExit",             function(mouseEvent) ... end)
      gui.addHandler("mouseDown",             function(mouseEvent) ... end)
      gui.addHandler("mouseDrag",             function(mouseEvent) ... end)
      gui.addHandler("mouseUp",               function(mouseEvent) ... end)
      gui.addHandler("mouseDoubleClick",      function(mouseEvent) ... end)
      gui.addHandler("mouseWheelMove",        function(mouseEvent, mouseWheelDetails) ... end)
      gui.addHandler("keyPressed",            function(keyPress, srcComponent) ... end)
      gui.addHandler("keyStateChanged",       function(keyPress, srcComponent) ... end)

  Parameters received by the event handlers are of type FocusCause, ModifierKeys, MouseEvent, MouseWheelDetails, and KeyPress.

  ### Parameters:

  - event string the event to handle
  - handler function a function to add the event's handlers

  ### See also:

  - script.addHandler
  - plugin.addHandler
gui.paint (g)
  Override to paint a custom GUI. Define this function to paint something in the custom GUI space.

  ### Parameters:

  - g juce.Graphics a JUCE graphics target
gui.getComponent ()
  Get GUI Component.

  ### Returns:

  the current GUI component, or `nil` if the GUI has not been opened yet.

## Tables

gui.FocusCause
  Focus change causes. Values received by the `focusGained` and `focusLost` handlers.

  ### Fields:

  - focusChangedByMouseClick 0
  - focusChangedByTabKey 1
  - focusChangedDirectly 2

  ### See also:

  gui.addHandler
gui.ModifierKeys
  Keyboard and mouse modifiers. Contained in every gui.MouseEvent and received by the `modifierKeysChanged` handler.

  ### Fields:

  - noModifiers 0
  - shiftModifier 1
  - ctrlModifier 2
  - altModifier 4
  - leftButtonModifier 16
  - rightButtonModifier 32
  - middleButtonModifier 64
  - commandModifier 8
  - ctrlAltCommandModifiers 14

## Class gui.MouseEvent

A mouse event as received by GUI handlers (see gui.addHandler)

gui.MouseEvent.x
  X.
gui.MouseEvent.y
  Y.
gui.MouseEvent.mods
  Modifier keys. Values defined in gui.ModifierKeys
gui.MouseEvent.eventComponent
  Event component.
gui.MouseEvent.originalComponent
  Original component.
gui.MouseEvent.eventTime
  Time.
gui.MouseEvent.mouseDownTime
  Mouse down time.
gui.MouseEvent.mouseDownPos
  Mouse down position.
gui.MouseEvent.numberOfClicks
  Number of clicks.
gui.MouseEvent.wasMovedSinceMouseDown
  Was moved since mouse down.

## Class gui.MouseWheelDetails

As received by the `mouseWheelMove` handler (see gui.addHandler)

gui.MouseWheelDetails.deltaX
  X delta.
gui.MouseWheelDetails.deltaY
  Y delta.
gui.MouseWheelDetails.isReversed
  Is reversed.
gui.MouseWheelDetails.isSmooth
  Is smooth.

## Class gui.KeyPress

As received by the `keyPressed` and `keyStateChanged` handlers (see gui.addHandler)

gui.KeyPress.keyCode
  Key code. (undecipherable for now)
gui.KeyPress.mods
  Modifier Keys.
gui.KeyPress.textCharacter
  Text character.

generated by LDoc 1.4.2