Fix input and draw for the rect view nodes.

This commit is contained in:
Relintai 2022-04-14 01:04:20 +02:00
parent 29972b6f6d
commit ea20b2fd09
2 changed files with 14 additions and 8 deletions

View File

@ -367,7 +367,7 @@ void MDRUVRectViewNode::_draw() {
} }
//based on / ported from engine/scene/gui/dialogs.h and .cpp //based on / ported from engine/scene/gui/dialogs.h and .cpp
void MDRUVRectViewNode::_gui_input(Ref<InputEvent> p_event) { void MDRUVRectViewNode::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event; Ref<InputEventMouseButton> mb = p_event;
if ((mb.is_valid()) && (mb->get_button_index() == BUTTON_LEFT)) { if ((mb.is_valid()) && (mb->get_button_index() == BUTTON_LEFT)) {
@ -503,13 +503,18 @@ int MDRUVRectViewNode::_drag_hit_test(Vector2 pos) {
//based on / ported from engine/scene/gui/dialogs.h and .cpp //based on / ported from engine/scene/gui/dialogs.h and .cpp
void MDRUVRectViewNode::_notification(int p_what) { void MDRUVRectViewNode::_notification(int p_what) {
if (p_what == NOTIFICATION_MOUSE_EXIT) { switch(p_what) {
// Reset the mouse cursor when leaving the resizable window border. case NOTIFICATION_MOUSE_EXIT: {
if (_mdr.is_valid() && !drag_type) { // Reset the mouse cursor when leaving the resizable window border.
if (get_default_cursor_shape() != CURSOR_ARROW) { if (_mdr.is_valid() && !drag_type) {
set_default_cursor_shape(CURSOR_ARROW); if (get_default_cursor_shape() != CURSOR_ARROW) {
set_default_cursor_shape(CURSOR_ARROW);
}
} }
} } break;
case NOTIFICATION_DRAW: {
_draw();
} break;
} }
} }
@ -536,4 +541,5 @@ MDRUVRectViewNode::~MDRUVRectViewNode() {
} }
void MDRUVRectViewNode::_bind_methods() { void MDRUVRectViewNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &MDRUVRectViewNode::_gui_input);
} }

View File

@ -63,7 +63,7 @@ public:
void refresh(); void refresh();
void _draw(); void _draw();
void _gui_input(Ref<InputEvent> p_event); void _gui_input(const Ref<InputEvent> &p_event);
int _drag_hit_test(Vector2 pos); int _drag_hit_test(Vector2 pos);
MDRUVRectViewNode(); MDRUVRectViewNode();