WPILibC++  2020.3.2-60-g3011ebe
frc::Button Class Reference

This class provides an easy way to link commands to OI inputs. More...

#include <Button.h>

Inheritance diagram for frc::Button:
frc::Trigger frc::Sendable frc::SendableHelper< Trigger > frc::InternalButton frc::JoystickButton frc::NetworkButton frc::POVButton

Public Member Functions

 Button (Button &&)=default
 
Buttonoperator= (Button &&)=default
 
virtual void WhenPressed (Command *command)
 Specifies the command to run when a button is first pressed. More...
 
virtual void WhileHeld (Command *command)
 Specifies the command to be scheduled while the button is pressed. More...
 
virtual void WhenReleased (Command *command)
 Specifies the command to run when the button is released. More...
 
virtual void CancelWhenPressed (Command *command)
 Cancels the specificed command when the button is pressed. More...
 
virtual void ToggleWhenPressed (Command *command)
 Toggle the specified command when the button is pressed. More...
 
- Public Member Functions inherited from frc::Trigger
 Trigger (const Trigger &rhs)
 
Triggeroperator= (const Trigger &rhs)
 
 Trigger (Trigger &&rhs)
 
Triggeroperator= (Trigger &&rhs)
 
bool Grab ()
 
virtual bool Get ()=0
 
void WhenActive (Command *command)
 
void WhileActive (Command *command)
 
void WhenInactive (Command *command)
 
void CancelWhenActive (Command *command)
 
void ToggleWhenActive (Command *command)
 
void InitSendable (SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from frc::SendableHelper< Trigger >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 
std::string GetName () const
 Gets the name of this Sendable object. More...
 
void SetName (const wpi::Twine &name)
 Sets the name of this Sendable object. More...
 
void SetName (const wpi::Twine &subsystem, const wpi::Twine &name)
 Sets both the subsystem name and device name of this Sendable object. More...
 
std::string GetSubsystem () const
 Gets the subsystem name of this Sendable object. More...
 
void SetSubsystem (const wpi::Twine &subsystem)
 Sets the subsystem name of this Sendable object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from frc::SendableHelper< Trigger >
void SetName (const wpi::Twine &moduleType, int channel)
 Sets the name of the sensor with a channel number. More...
 
void SetName (const wpi::Twine &moduleType, int moduleNumber, int channel)
 Sets the name of the sensor with a module and channel number. More...
 
void AddChild (std::shared_ptr< Sendable > child)
 Add a child component. More...
 
void AddChild (void *child)
 Add a child component. More...
 

Detailed Description

This class provides an easy way to link commands to OI 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.

This class represents a subclass of Trigger that is specifically aimed at buttons on an operator interface as a common use case of the more generalized Trigger objects. This is a simple wrapper around Trigger with the method names renamed to fit the Button object use.

Member Function Documentation

◆ CancelWhenPressed()

virtual void frc::Button::CancelWhenPressed ( Command command)
virtual

Cancels the specificed command when the button is pressed.

Parameters
commandThe command to be canceled

◆ ToggleWhenPressed()

virtual void frc::Button::ToggleWhenPressed ( Command command)
virtual

Toggle the specified command when the button is pressed.

Parameters
commandThe command to be toggled

◆ WhenPressed()

virtual void frc::Button::WhenPressed ( Command command)
virtual

Specifies the command to run when a button is first pressed.

Parameters
commandThe pointer to the command to run

◆ WhenReleased()

virtual void frc::Button::WhenReleased ( Command command)
virtual

Specifies the command to run when the button is released.

The command will be scheduled a single time.

Parameters
commandThe pointer to the command to run

◆ WhileHeld()

virtual void frc::Button::WhileHeld ( Command command)
virtual

Specifies the command to be scheduled while the button is pressed.

The command will be scheduled repeatedly while the button is pressed and will be canceled when the button is released.

Parameters
commandThe pointer to the command to run

The documentation for this class was generated from the following file: