ModifierButtons
-
class ModifierButtons
This class monitors the state of a number of individual buttons and tracks whether each button is known to be down or up.
Inheritance diagram
-
ModifierButtons(void)
-
ModifierButtons(ModifierButtons const ©)
-
bool add_button(ButtonHandle button)
Adds the indicated button to the set of buttons that will be monitored for upness and downness. Returns true if the button was added, false if it was already being monitored or if too many buttons are currently being monitored.
-
void all_buttons_up(void)
Marks all monitored buttons as being in the “up” state.
-
bool button_down(ButtonHandle button)
Records that a particular button has been pressed. If the given button is one of the buttons that is currently being monitored, this will update the internal state appropriately; otherwise, it will do nothing. Returns true if the button is one that was monitored, or false otherwise.
-
bool button_up(ButtonHandle button)
Records that a particular button has been released. If the given button is one of the buttons that is currently being monitored, this will update the internal state appropriately; otherwise, it will do nothing. Returns true if the button is one that was monitored, or false otherwise.
-
ButtonHandle get_button(int index) const
Returns the nth button that the
ModifierButtons
object is monitoring (the nth button passed toadd_button()
). This must be in the range 0 <= index <get_num_buttons()
.
-
int get_num_buttons(void) const
Returns the number of buttons that the
ModifierButtons
object is monitoring (e.g. the number of buttons passed toadd_button()
).
-
std::string get_prefix(void) const
Returns a string which can be used to prefix any button name or event name with the unique set of modifier buttons currently being held.
-
bool has_button(ButtonHandle button) const
Returns true if the indicated button is in the set of buttons being monitored, false otherwise.
-
bool is_any_down(void) const
Returns true if any of the tracked button are known to be down, or false if all of them are up.
-
bool is_down(ButtonHandle button) const
-
bool is_down(int index) const
Returns true if the indicated button is known to be down, or false if it is known to be up.
Returns true if the indicated button is known to be down, or false if it is known to be up or if it is not in the set of buttons being tracked.
-
bool matches(ModifierButtons const &other) const
Returns true if the set of buttons indicated as down by this
ModifierButtons
object is the same set of buttons indicated as down by the otherModifierButtons
object. The buttons indicated as up are not relevant.
-
void output(std::ostream &out) const
Writes a one-line summary of the buttons known to be down.
-
bool remove_button(ButtonHandle button)
Removes the indicated button from the set of buttons being monitored. Returns true if the button was removed, false if it was not being monitored in the first place.
Unlike the other methods, you cannot remove a button by removing its alias; you have to remove exactly the button itself.
-
void set_button_list(ModifierButtons const &other)
Sets the list of buttons to watch to be the same as that of the other
ModifierButtons
object. This makes the lists pointer equivalent (until one or the other is later modified).This will preserve the state of any button that was on the original list and is also on the new lists. Any other buttons will get reset to the default state of “up”.
-
void write(std::ostream &out) const
Writes a multi-line summary including all of the buttons being monitored and which ones are known to be down.
-
ModifierButtons(void)