PGItem
from panda3d.core import PGItem
- class PGItem
Bases:
Bases:
PandaNode
This is the base class for all the various kinds of gui widget objects.
It is a Node which corresponds to a rectangular region on the screen, and it may have any number of “state” subgraphs, one of which is rendered at any given time according to its current state.
The PGItem node must be parented to the scene graph somewhere beneath a
PGTop
node in order for this behavior to work.Inheritance diagram
- property active bool
- Getter
Returns whether the
PGItem
is currently active for mouse events. Seeset_active()
.- Setter
Sets whether the
PGItem
is active for mouse watching. This is not necessarily related to the active/inactive appearance of the item, which is controlled byset_state()
, but it does affect whether it responds to mouse events.
- property background_focus bool
- Getter
Returns whether background_focus is currently enabled. See
set_background_focus()
.- Setter
Sets the background_focus flag for this item. When background_focus is enabled, the item will receive keypress events even if it is not in focus; in fact, even if it is not onscreen. Unlike normal focus, many items may have background_focus simultaneously.
- clear_frame()
Removes the bounding rectangle from the item. It will no longer be possible to position the mouse within the item; see
set_frame()
.
- clear_state_def(state: int)
Resets the
NodePath
assigned to the indicated state to its initial default, with only a frame representation if appropriate.
- property focus bool
- Getter
Returns whether the
PGItem
currently has focus for keyboard events. Seeset_focus()
.- Setter
Sets whether the
PGItem
currently has keyboard focus. This simply means that the item may respond to keyboard events as well as to mouse events; precisely what this means is up to the individual item.Only one
PGItem
in the world is allowed to have focus at any given time. Setting the focus on any other item automatically disables the focus from the previous item.
- property frame LVecBase4
- Getter
Returns the bounding rectangle of the item. See
set_frame()
. It is an error to call this ifhas_frame()
returns false.- Setter
Sets the bounding rectangle of the item, in local coordinates. This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.
Sets the bounding rectangle of the item, in local coordinates. This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.
- get_active() bool
Returns whether the
PGItem
is currently active for mouse events. Seeset_active()
.
- get_background_focus() bool
Returns whether background_focus is currently enabled. See
set_background_focus()
.
- static get_class_type() TypeHandle
- get_enter_event() str
Returns the event name that will be thrown when the item is active and the mouse enters its frame, but not any nested frames.
- static get_enter_prefix() str
Returns the prefix that is used to define the enter event for all
PGItems
. The enter event is the concatenation of this string followed byget_id()
.
- get_exit_event() str
Returns the event name that will be thrown when the item is active and the mouse exits its frame, or enters a nested frame.
- static get_exit_prefix() str
Returns the prefix that is used to define the exit event for all
PGItems
. The exit event is the concatenation of this string followed byget_id()
.
- get_focus() bool
Returns whether the
PGItem
currently has focus for keyboard events. Seeset_focus()
.
- get_focus_in_event() str
Returns the event name that will be thrown when the item gets the keyboard focus.
- static get_focus_in_prefix() str
Returns the prefix that is used to define the focus_in event for all
PGItems
. The focus_in event is the concatenation of this string followed byget_id()
.Unlike most item events, this event is thrown with no parameters.
- static get_focus_item() PGItem
Returns the one
PGItem
in the world that currently has keyboard focus, if any, or NULL if no item has keyboard focus. UsePGItem.set_focus()
to activate or deactivate keyboard focus on a particular item.
- get_focus_out_event() str
Returns the event name that will be thrown when the item loses the keyboard focus.
- static get_focus_out_prefix() str
Returns the prefix that is used to define the focus_out event for all
PGItems
. The focus_out event is the concatenation of this string followed byget_id()
.Unlike most item events, this event is thrown with no parameters.
- get_frame() LVecBase4
Returns the bounding rectangle of the item. See
set_frame()
. It is an error to call this ifhas_frame()
returns false.
- get_frame_style(state: int) PGFrameStyle
Returns the kind of frame that will be drawn behind the item when it is in the indicated state.
- get_id() str
Returns the unique ID assigned to this
PGItem
. This will be assigned to the region created with theMouseWatcher
, and will thus be used to generate event names.
- get_keystroke_event() str
Returns the event name that will be thrown when the item is active and any key is pressed by the user.
- static get_keystroke_prefix() str
Returns the prefix that is used to define the keystroke event for all
PGItems
. The keystroke event is the concatenation of this string followed by a hyphen andget_id()
.
- get_num_state_defs() int
Returns one more than the highest-numbered state def that was ever assigned to the
PGItem
. The complete set of state defs assigned may then be retrieved by indexing from 0 to (get_num_state_defs() - 1).This is only an upper limit on the actual number of state defs, since there may be holes in the list.
- get_press_event(button: ButtonHandle) str
Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is depressed while the mouse is within the frame.
- static get_press_prefix() str
Returns the prefix that is used to define the press event for all
PGItems
. The press event is the concatenation of this string followed by a button name, followed by a hyphen andget_id()
.
- get_release_event(button: ButtonHandle) str
Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button, formerly clicked down is within the frame, is released.
- static get_release_prefix() str
Returns the prefix that is used to define the release event for all
PGItems
. The release event is the concatenation of this string followed by a button name, followed by a hyphen andget_id()
.
- get_repeat_event(button: ButtonHandle) str
Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is continuously held down while the mouse is within the frame.
- static get_repeat_prefix() str
Returns the prefix that is used to define the repeat event for all
PGItems
. The repeat event is the concatenation of this string followed by a button name, followed by a hyphen andget_id()
.
- get_sound(event: str) AudioSound
Returns the sound associated with the indicated event, or NULL if there is no associated sound.
- get_state() int
Returns the “state” of this particular
PGItem
. Seeset_state()
.
- get_state_def(state: int) NodePath
Returns the Node that is the root of the subgraph that will be drawn when the
PGItem
is in the indicated state. The first time this is called for a particular state index, it may create the Node.
- get_suppress_flags() int
This is just an interface to get the suppress flags on the underlying
MouseWatcherRegion
. SeeMouseWatcherRegion.get_suppress_flags()
.
- static get_text_node() TextNode
Returns the
TextNode
object that will be used by allPGItems
to generate default labels given a string. This can be loaded with the default font, etc.
- get_within_event() str
Returns the event name that will be thrown when the item is active and the mouse moves within the boundaries of the frame. This is different from the enter_event in that the mouse is considered within the frame even if it is also within a nested frame.
- static get_within_prefix() str
Returns the prefix that is used to define the within event for all
PGItems
. The within event is the concatenation of this string followed byget_id()
.
- get_without_event() str
Returns the event name that will be thrown when the item is active and the mouse moves completely outside the boundaries of the frame. This is different from the exit_event in that the mouse is considered within the frame even if it is also within a nested frame.
- static get_without_prefix() str
Returns the prefix that is used to define the without event for all
PGItems
. The without event is the concatenation of this string followed byget_id()
.
- has_frame() bool
Returns true if the item has a bounding rectangle; see
set_frame()
.
- has_sound(event: str) bool
Returns true if there is a sound associated with the indicated event, or false otherwise.
- has_state_def(state: int) bool
Returns true if
get_state_def()
has ever been called for the indicated state (thus defining a render subgraph for this state index), false otherwise.
- property id string
- Getter
Returns the unique ID assigned to this
PGItem
. This will be assigned to the region created with theMouseWatcher
, and will thus be used to generate event names.- Setter
Set the unique ID assigned to this
PGItem
. It is the user’s responsibility to ensure that this ID is unique.Normally, this should not need to be called, as the
PGItem
will assign itself an ID when it is created, but this function allows the user to decide to redefine the ID to be something possibly more meaningful.
- instance_to_state_def(state: int, path: NodePath) NodePath
Parents an instance of the bottom node of the indicated
NodePath
to the indicated state index.
- property name string
- set_active(active: bool)
Sets whether the
PGItem
is active for mouse watching. This is not necessarily related to the active/inactive appearance of the item, which is controlled byset_state()
, but it does affect whether it responds to mouse events.
- set_background_focus(focus: bool)
Sets the background_focus flag for this item. When background_focus is enabled, the item will receive keypress events even if it is not in focus; in fact, even if it is not onscreen. Unlike normal focus, many items may have background_focus simultaneously.
- set_focus(focus: bool)
Sets whether the
PGItem
currently has keyboard focus. This simply means that the item may respond to keyboard events as well as to mouse events; precisely what this means is up to the individual item.Only one
PGItem
in the world is allowed to have focus at any given time. Setting the focus on any other item automatically disables the focus from the previous item.
- set_frame(frame: LVecBase4)
Sets the bounding rectangle of the item, in local coordinates. This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.
- set_frame(left: float, right: float, bottom: float, top: float)
Sets the bounding rectangle of the item, in local coordinates. This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.
- set_frame_style(state: int, style: PGFrameStyle)
Changes the kind of frame that will be drawn behind the item when it is in the indicated state.
- set_id(id: str)
Set the unique ID assigned to this
PGItem
. It is the user’s responsibility to ensure that this ID is unique.Normally, this should not need to be called, as the
PGItem
will assign itself an ID when it is created, but this function allows the user to decide to redefine the ID to be something possibly more meaningful.
- set_sound(event: str, sound: AudioSound)
Sets the sound that will be played whenever the indicated event occurs.
- set_state(state: int)
Sets the “state” of this particular
PGItem
.The
PGItem
node will render as if it were the subgraph assigned to the corresponding index via set_state_def().
- set_suppress_flags(suppress_flags: int)
This is just an interface to set the suppress flags on the underlying
MouseWatcherRegion
. SeeMouseWatcherRegion.set_suppress_flags()
.
- static set_text_node(node: TextNode)
Changes the
TextNode
object that will be used by allPGItems
to generate default labels given a string. This can be loaded with the default font, etc.
- property state int
- Getter
Returns the “state” of this particular
PGItem
. Seeset_state()
.- Setter
Sets the “state” of this particular
PGItem
.The
PGItem
node will render as if it were the subgraph assigned to the corresponding index via set_state_def().
- property suppress_flags int
This is just an interface to get/set the suppress flags on the underlying
MouseWatcherRegion
. SeeMouseWatcherRegion.get_suppress_flags()
.MouseWatcherRegion.set_suppress_flags()
.