PGButton

class PGButton

Bases: PGItem

This is a particular kind of PGItem that is specialized to behave like a normal button object. It keeps track of its own state, and handles mouse events sensibly.

Inheritance diagram

Inheritance diagram of PGButton

enum State
enumerator S_ready = 0
enumerator S_depressed = 1
enumerator S_rollover = 2
enumerator S_inactive = 3
explicit PGButton(std::string const &name)
bool add_click_button(ButtonHandle const &button)

Adds the indicated button to the set of buttons that can effectively “click” the PGButton. Normally, this is just MouseButton::one(). Returns true if the button was added, or false if it was already there.

static TypeHandle get_class_type(void)
std::string get_click_event(ButtonHandle const &button) const

Returns the event name that will be thrown when the button is clicked normally.

std::string get_click_prefix(void)

Returns the prefix that is used to define the click event for all PGButtons. The click event is the concatenation of this string followed by get_id().

bool has_click_button(ButtonHandle const &button)

Returns true if the indicated button is on the set of buttons that can effectively “click” the PGButton. Normally, this is just MouseButton::one().

bool is_button_down(void)

Returns true if the user is currently holding the mouse button down on the button, false otherwise.

bool remove_click_button(ButtonHandle const &button)

Removes the indicated button from the set of buttons that can effectively “click” the PGButton. Normally, this is just MouseButton::one(). Returns true if the button was removed, or false if it was not in the set.

void setup(std::string const &label, PN_stdfloat bevel = 0.1)
void setup(NodePath const &ready)
void setup(NodePath const &ready, NodePath const &depressed)
void setup(NodePath const &ready, NodePath const &depressed, NodePath const &rollover)
void setup(NodePath const &ready, NodePath const &depressed, NodePath const &rollover, NodePath const &inactive)

Sets up the button using the indicated NodePath as arbitrary geometry.

Sets up the button using the indicated NodePath as arbitrary geometry.

Sets up the button using the indicated NodePath as arbitrary geometry.

Sets up the button as a default text button using the indicated label string. The TextNode defined by PGItem::get_text_node() will be used to create the label geometry. This automatically sets up the frame according to the size of the text.

Sets up the button using the indicated NodePath as arbitrary geometry.