Panda3D
Loading...
Searching...
No Matches
pgButton.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pgButton.I
10 * @author drose
11 * @date 2002-03-13
12 */
13
14/**
15 * Sets the object which will be notified when the PGButton changes. Set this
16 * to NULL to disable this effect. The PGButton does not retain ownership of
17 * the pointer; it is your responsibility to ensure that the notify object
18 * does not destruct.
19 */
20INLINE void PGButton::
22 PGItem::set_notify(notify);
23}
24
25/**
26 * Returns the object which will be notified when the PGButton changes, if
27 * any. Returns NULL if there is no such object configured.
28 */
33
34/**
35 * Sets up the button using the indicated NodePath as arbitrary geometry.
36 */
37INLINE void PGButton::
38setup(const NodePath &ready) {
39 setup(ready, ready, ready, ready);
40}
41
42/**
43 * Sets up the button using the indicated NodePath as arbitrary geometry.
44 */
45INLINE void PGButton::
46setup(const NodePath &ready, const NodePath &depressed) {
47 setup(ready, depressed, ready, ready);
48}
49
50/**
51 * Sets up the button using the indicated NodePath as arbitrary geometry.
52 */
53INLINE void PGButton::
54setup(const NodePath &ready, const NodePath &depressed,
55 const NodePath &rollover) {
56 setup(ready, depressed, rollover, ready);
57}
58
59/**
60 * Returns the prefix that is used to define the click event for all
61 * PGButtons. The click event is the concatenation of this string followed by
62 * get_id().
63 */
64INLINE std::string PGButton::
66 return "click-";
67}
68
69/**
70 * Returns the event name that will be thrown when the button is clicked
71 * normally.
72 */
73INLINE std::string PGButton::
74get_click_event(const ButtonHandle &button) const {
75 LightReMutexHolder holder(_lock);
76 return get_click_prefix() + button.get_name() + "-" + get_id();
77}
78
79/**
80 * Returns true if the user is currently holding the mouse button down on the
81 * button, false otherwise.
82 */
83INLINE bool PGButton::
85 LightReMutexHolder holder(_lock);
86 return _button_down;
87}
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
get_name
Returns the name of the button.
Similar to MutexHolder, but for a light reentrant mutex.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
Objects that inherit from this class can receive notify messages when a slider bar moves or otherwise...
void setup(const std::string &label, PN_stdfloat bevel=0.1f)
Sets up the button as a default text button using the indicated label string.
Definition pgButton.cxx:157
bool is_button_down()
Returns true if the user is currently holding the mouse button down on the button,...
Definition pgButton.I:84
get_click_prefix
Returns the prefix that is used to define the click event for all PGButtons.
Definition pgButton.h:76
std::string get_click_event(const ButtonHandle &button) const
Returns the event name that will be thrown when the button is clicked normally.
Definition pgButton.I:74
void set_notify(PGButtonNotify *notify)
Sets the object which will be notified when the PGButton changes.
Definition pgButton.I:21
PGButtonNotify * get_notify() const
Returns the object which will be notified when the PGButton changes, if any.
Definition pgButton.I:30
void set_notify(PGItemNotify *notify)
Sets the object which will be notified when the PGItem changes.
Definition pgItem.I:43
PGItemNotify * get_notify() const
Returns the object which will be notified when the PGItem changes, if any.
Definition pgItem.I:69
const std::string & get_id() const
Returns the unique ID assigned to this PGItem.
Definition pgItem.I:224