Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.wpi.first.wpilibj.buttons
Class Trigger

    java.lang.Object
      edu.wpi.first.wpilibj.buttons.Trigger

All Implemented Interfaces:
  Sendable

Direct Known Subclasses:
  AnalogIOButton, Button

    public abstract class Trigger

extends Object
implements Sendable

This class provides an easy way to link commands to inputs. It is very easy to link a button to a command. For instance, you could link the trigger button of a joystick to a "score" command. It is encouraged that teams write a subclass of Trigger if they want to have something unusual (for instance, if they want to react to the user holding a button while the robot is reading a certain sensor input). For this, they only have to write the `get()` method to get the full functionality of the Trigger class.

Author:
  Joe Grinstead

Nested Class Summary
`class` | `Trigger.ButtonScheduler` An internal class of `Trigger`.

Constructor Summary
`Trigger()`

Method Summary
`void` | `cancelWhenActive(Command command)` Cancels a command when the trigger becomes active
`abstract boolean` | `get()` Returns whether or not the trigger is active This method will be called repeatedly a command is linked to the Trigger.
`String` | `getSmartDashboardType()` These methods continue to return the "Button" SmartDashboard type until we decided to create a Trigger widget type for the dashboard.
`ITable` | `getTable()`
`void` | `initTable(ITable table)` Initializes a table for this sendable object.
`void` | `toggleWhenActive(Command command)` Toggles a command when the trigger becomes active
`void` | `whenActive(Command command)` Starts the given command whenever the trigger just becomes active.
`void` | `whenInactive(Command command)` Starts the command when the trigger becomes inactive
`void` | `whileActive(Command command)` Constantly starts the given command while the button is held.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Trigger

    public Trigger()

Method Detail

### get

    public abstract boolean get()

  Returns whether or not the trigger is active This method will be called repeatedly a command is linked to the Trigger.

  Returns:
    whether or not the trigger condition is active.

### whenActive

    public void whenActive(Command command)

  Starts the given command whenever the trigger just becomes active.

  Parameters:
    `command` - the command to start

### whileActive

    public void whileActive(Command command)

  Constantly starts the given command while the button is held. `Command.start()` will be called repeatedly while the trigger is active, and will be canceled when the trigger becomes inactive.

  Parameters:
    `command` - the command to start

### whenInactive

    public void whenInactive(Command command)

  Starts the command when the trigger becomes inactive

  Parameters:
    `command` - the command to start

### toggleWhenActive

    public void toggleWhenActive(Command command)

  Toggles a command when the trigger becomes active

  Parameters:
    `command` - the command to toggle

### cancelWhenActive

    public void cancelWhenActive(Command command)

  Cancels a command when the trigger becomes active

  Parameters:
    `command` - the command to cancel

### getSmartDashboardType

    public String getSmartDashboardType()

  These methods continue to return the "Button" SmartDashboard type until we decided to create a Trigger widget type for the dashboard.

  Specified by:
    `getSmartDashboardType` in interface `Sendable`
  Returns:
    the string representation of the named data type that will be used by the smart dashboard for this sendable

### initTable

    public void initTable(ITable table)

  Description copied from interface: `Sendable`
  Initializes a table for this sendable object.

  Specified by:
    `initTable` in interface `Sendable`
  Parameters:
    `table` - The table to put the values in.

### getTable

    public ITable getTable()

  Specified by:
    `getTable` in interface `Sendable`
  Returns:
    the table that is currently associated with the sendable

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"