Skip to content

Commit

Permalink
Merge pull request #93967 from dalexeev/editor-fix-help-bit-tooltip-f…
Browse files Browse the repository at this point in the history
…or-signals

Editor: Fix `EditorHelpBitTooltip` for Signals dock
  • Loading branch information
akien-mga committed Jul 7, 2024
2 parents dc34cb0 + ec2f935 commit 1cfcc04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 18 additions & 5 deletions editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3761,6 +3761,12 @@ EditorHelpBit::EditorHelpBit(const String &p_symbol) {

/// EditorHelpBitTooltip ///

void EditorHelpBitTooltip::_start_timer() {
if (timer->is_inside_tree() && timer->is_stopped()) {
timer->start();
}
}

void EditorHelpBitTooltip::_safe_queue_free() {
if (_pushing_input > 0) {
_need_free = true;
Expand All @@ -3769,21 +3775,28 @@ void EditorHelpBitTooltip::_safe_queue_free() {
}
}

void EditorHelpBitTooltip::_target_gui_input(const Ref<InputEvent> &p_event) {
const Ref<InputEventMouse> mouse_event = p_event;
if (mouse_event.is_valid()) {
_start_timer();
}
}

void EditorHelpBitTooltip::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_WM_MOUSE_ENTER:
timer->stop();
break;
case NOTIFICATION_WM_MOUSE_EXIT:
timer->start();
_start_timer();
break;
}
}

// Forwards non-mouse input to the parent viewport.
void EditorHelpBitTooltip::_input_from_window(const Ref<InputEvent> &p_event) {
if (p_event->is_action_pressed(SNAME("ui_cancel"), false, true)) {
hide(); // Will be deleted on its timer.
_safe_queue_free();
} else {
const Ref<InputEventMouse> mouse_event = p_event;
if (mouse_event.is_null()) {
Expand All @@ -3801,7 +3814,7 @@ void EditorHelpBitTooltip::_input_from_window(const Ref<InputEvent> &p_event) {
void EditorHelpBitTooltip::show_tooltip(EditorHelpBit *p_help_bit, Control *p_target) {
ERR_FAIL_NULL(p_help_bit);
EditorHelpBitTooltip *tooltip = memnew(EditorHelpBitTooltip(p_target));
p_help_bit->connect("request_hide", callable_mp(static_cast<Window *>(tooltip), &Window::hide)); // Will be deleted on its timer.
p_help_bit->connect("request_hide", callable_mp(tooltip, &EditorHelpBitTooltip::_safe_queue_free));
tooltip->add_child(p_help_bit);
p_target->get_viewport()->add_child(tooltip);
p_help_bit->update_content_height();
Expand Down Expand Up @@ -3858,8 +3871,8 @@ EditorHelpBitTooltip::EditorHelpBitTooltip(Control *p_target) {
add_child(timer);

ERR_FAIL_NULL(p_target);
p_target->connect(SceneStringName(mouse_entered), callable_mp(timer, &Timer::stop));
p_target->connect(SceneStringName(mouse_exited), callable_mp(timer, &Timer::start).bind(-1));
p_target->connect(SceneStringName(mouse_exited), callable_mp(this, &EditorHelpBitTooltip::_start_timer));
p_target->connect(SceneStringName(gui_input), callable_mp(this, &EditorHelpBitTooltip::_target_gui_input));
}

#if defined(MODULE_GDSCRIPT_ENABLED) || defined(MODULE_MONO_ENABLED)
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ class EditorHelpBitTooltip : public PopupPanel {
int _pushing_input = 0;
bool _need_free = false;

void _start_timer();
void _safe_queue_free();
void _target_gui_input(const Ref<InputEvent> &p_event);

protected:
void _notification(int p_what);
Expand Down

0 comments on commit 1cfcc04

Please sign in to comment.