Merge pull request #26140 from karliss/meta-item

Use correct meta item in rich text.
This commit is contained in:
Rémi Verschelde 2019-03-01 18:16:27 +01:00 committed by GitHub
commit 994bdc9adc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -1133,12 +1133,13 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
} }
Variant meta; Variant meta;
if (item && !outside && _find_meta(item, &meta)) { ItemMeta *item_meta;
if (meta_hovering != item) { if (item && !outside && _find_meta(item, &meta, &item_meta)) {
if (meta_hovering != item_meta) {
if (meta_hovering) { if (meta_hovering) {
emit_signal("meta_hover_ended", current_meta); emit_signal("meta_hover_ended", current_meta);
} }
meta_hovering = static_cast<ItemMeta *>(item); meta_hovering = item_meta;
current_meta = meta; current_meta = meta;
emit_signal("meta_hover_started", meta); emit_signal("meta_hover_started", meta);
} }
@ -1269,7 +1270,7 @@ bool RichTextLabel::_find_strikethrough(Item *p_item) {
return false; return false;
} }
bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta) { bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item) {
Item *item = p_item; Item *item = p_item;
@ -1280,6 +1281,8 @@ bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta) {
ItemMeta *meta = static_cast<ItemMeta *>(item); ItemMeta *meta = static_cast<ItemMeta *>(item);
if (r_meta) if (r_meta)
*r_meta = meta->meta; *r_meta = meta->meta;
if (r_item)
*r_item = meta;
return true; return true;
} }

View file

@ -285,7 +285,7 @@ private:
Color _find_color(Item *p_item, const Color &p_default_color); Color _find_color(Item *p_item, const Color &p_default_color);
bool _find_underline(Item *p_item); bool _find_underline(Item *p_item);
bool _find_strikethrough(Item *p_item); bool _find_strikethrough(Item *p_item);
bool _find_meta(Item *p_item, Variant *r_meta); bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = NULL);
void _update_scroll(); void _update_scroll();
void _scroll_changed(double); void _scroll_changed(double);