Expose Node
child manipulation callbacks
Corrected Control's not calling base child_notify methods Corrected Window not calling base child_notify methods
This commit is contained in:
parent
62792eeb9f
commit
27da0deb03
4 changed files with 39 additions and 3 deletions
|
@ -22,6 +22,14 @@
|
|||
<link title="All Demos">https://github.com/godotengine/godot-demo-projects/</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="_add_child_notify" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<param index="0" name="child" type="Node" />
|
||||
<description>
|
||||
Called after a node is added as a child.
|
||||
[b]Note:[/b] This method is called on application start for every node already in the tree as well.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_enter_tree" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<description>
|
||||
|
@ -55,6 +63,13 @@
|
|||
[b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
|
||||
</description>
|
||||
</method>
|
||||
<method name="_move_child_notify" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<param index="0" name="child" type="Node" />
|
||||
<description>
|
||||
Called after a child is moved within the node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_physics_process" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<param index="0" name="delta" type="float" />
|
||||
|
@ -84,6 +99,13 @@
|
|||
[b]Note:[/b] [method _ready] may be called only once for each node. After removing a node from the scene tree and adding it again, [code]_ready[/code] will not be called a second time. This can be bypassed by requesting another call with [method request_ready], which may be called anywhere before adding the node again.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_remove_child_notify" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<param index="0" name="child" type="Node" />
|
||||
<description>
|
||||
Called when a child is removed within the node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_shortcut_input" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<param index="0" name="event" type="InputEvent" />
|
||||
|
|
|
@ -411,15 +411,18 @@ void Node::_propagate_groups_dirty() {
|
|||
}
|
||||
|
||||
void Node::add_child_notify(Node *p_child) {
|
||||
// to be used when not wanted
|
||||
// Called when a node is added as a child to this one.
|
||||
GDVIRTUAL_CALL(_add_child_notify, p_child);
|
||||
}
|
||||
|
||||
void Node::remove_child_notify(Node *p_child) {
|
||||
// to be used when not wanted
|
||||
// Called when a child is removed from this node.
|
||||
GDVIRTUAL_CALL(_remove_child_notify, p_child);
|
||||
}
|
||||
|
||||
void Node::move_child_notify(Node *p_child) {
|
||||
// to be used when not wanted
|
||||
// Called when a child is moved inside this node.
|
||||
GDVIRTUAL_CALL(_move_child_notify, p_child);
|
||||
}
|
||||
|
||||
void Node::owner_changed_notify() {
|
||||
|
@ -2956,6 +2959,9 @@ void Node::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_shortcut_input, "event");
|
||||
GDVIRTUAL_BIND(_unhandled_input, "event");
|
||||
GDVIRTUAL_BIND(_unhandled_key_input, "event");
|
||||
GDVIRTUAL_BIND(_add_child_notify, "child");
|
||||
GDVIRTUAL_BIND(_remove_child_notify, "child");
|
||||
GDVIRTUAL_BIND(_move_child_notify, "child");
|
||||
}
|
||||
|
||||
String Node::_get_name_num_separator() {
|
||||
|
|
|
@ -246,6 +246,10 @@ protected:
|
|||
GDVIRTUAL1(_unhandled_input, Ref<InputEvent>)
|
||||
GDVIRTUAL1(_unhandled_key_input, Ref<InputEvent>)
|
||||
|
||||
GDVIRTUAL1(_add_child_notify, Node *)
|
||||
GDVIRTUAL1(_remove_child_notify, Node *)
|
||||
GDVIRTUAL1(_move_child_notify, Node *)
|
||||
|
||||
public:
|
||||
enum {
|
||||
// you can make your own, but don't use the same numbers as other notifications in other nodes
|
||||
|
|
|
@ -1284,12 +1284,16 @@ Rect2i Window::get_usable_parent_rect() const {
|
|||
}
|
||||
|
||||
void Window::add_child_notify(Node *p_child) {
|
||||
Viewport::add_child_notify(p_child);
|
||||
|
||||
if (is_inside_tree() && wrap_controls) {
|
||||
child_controls_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::remove_child_notify(Node *p_child) {
|
||||
Viewport::remove_child_notify(p_child);
|
||||
|
||||
if (is_inside_tree() && wrap_controls) {
|
||||
child_controls_changed();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue