SubZero Common
Common library components for an FRC CommandRobot
|
A SmartDashboard drop-down that can have its options dynamically change. More...
#include <ModifiableChooser.h>
Public Member Functions | |
ModifiableChooser () | |
~ModifiableChooser () | |
void | AddOption (std::string name, T object) |
Add a new option to the chooser. | |
void | RemoveOption (std::string name) |
Removes the option and updates the default option accoringly. | |
void | ClearOptions () |
Clears all options. | |
void | SetOptions (std::map< std::string, T > options) |
Populates options from an existing set. | |
void | SetDefaultOption (std::string name, T object) |
Set the default option to return. | |
void | SetOptions (std::map< std::string, T > options, std::string defaultName, T defaultObject) |
Set the options from an existing set along with a default. | |
T | GetSelected () |
Get the selected option. | |
std::string | GetSelectedKey () |
Get the selected key rather than the value. | |
std::string | GetNtSelected () |
void | SetNtSelected (std::string val) |
void | OnChange (std::function< void(std::optional< T >)> listener) |
Register a callback that gets executed whenever the selection changes. | |
void | InitSendable (wpi::SendableBuilder &builder) override |
A SmartDashboard drop-down that can have its options dynamically change.
T | The underlying value to return for a selected option |
Definition at line 29 of file ModifiableChooser.h.
subzero::ModifiableChooser< T >::ModifiableChooser | ( | ) |
subzero::ModifiableChooser< T >::~ModifiableChooser | ( | ) |
void subzero::ModifiableChooser< T >::AddOption | ( | std::string | name, |
T | object ) |
Add a new option to the chooser.
name | Name to display |
object | Value that gets returned upon selection |
void subzero::ModifiableChooser< T >::ClearOptions | ( | ) |
Clears all options.
std::string subzero::ModifiableChooser< T >::GetNtSelected | ( | ) |
T subzero::ModifiableChooser< T >::GetSelected | ( | ) |
Get the selected option.
std::string subzero::ModifiableChooser< T >::GetSelectedKey | ( | ) |
Get the selected key rather than the value.
|
override |
void subzero::ModifiableChooser< T >::OnChange | ( | std::function< void(std::optional< T >)> | listener | ) |
Register a callback that gets executed whenever the selection changes.
listener |
void subzero::ModifiableChooser< T >::RemoveOption | ( | std::string | name | ) |
Removes the option and updates the default option accoringly.
name |
void subzero::ModifiableChooser< T >::SetDefaultOption | ( | std::string | name, |
T | object ) |
Set the default option to return.
name | |
object |
void subzero::ModifiableChooser< T >::SetNtSelected | ( | std::string | val | ) |
void subzero::ModifiableChooser< T >::SetOptions | ( | std::map< std::string, T > | options | ) |
Populates options from an existing set.
options |
void subzero::ModifiableChooser< T >::SetOptions | ( | std::map< std::string, T > | options, |
std::string | defaultName, | ||
T | defaultObject ) |
Set the options from an existing set along with a default.
options | |
defaultName | |
defaultObject |