From 766d160ffb36528365c6a38ac93304781e5cecee Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Tue, 11 Feb 2020 19:53:09 +0100 Subject: guiHyperText: Fix blinky cursor on link hover (#9392) Change legacy size/position calculations to 'textarea' --- src/gui/guiFormSpecMenu.cpp | 31 +++++++++++++++---------------- src/gui/guiFormSpecMenu.h | 1 + 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/gui') diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 45eb0d17c..b96f53664 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -1634,11 +1634,9 @@ void GUIFormSpecMenu::parseHyperText(parserData *data, const std::string &elemen pos = getElementBasePos(&v_pos); pos -= padding; - pos.X += stof(v_pos[0]) * spacing.X; - pos.Y += stof(v_pos[1]) * spacing.Y + (m_btn_height * 2); - geom.X = (stof(v_geom[0]) * spacing.X) - (spacing.X - imgsize.X); - geom.Y = (stof(v_geom[1]) * imgsize.Y) - (spacing.Y - imgsize.Y); + geom.Y = (stof(v_geom[1]) * (float)imgsize.Y) - (spacing.Y - imgsize.Y); + pos.Y += m_btn_height; } core::rect rect = core::rect(pos.X, pos.Y, pos.X + geom.X, pos.Y + geom.Y); @@ -1653,7 +1651,7 @@ void GUIFormSpecMenu::parseHyperText(parserData *data, const std::string &elemen 258 + m_fields.size() ); - spec.ftype = f_Unknown; + spec.ftype = f_HyperText; GUIHyperText *e = new GUIHyperText(spec.flabel.c_str(), Environment, this, spec.fid, rect, m_client, m_tsrc); e->drop(); @@ -3309,7 +3307,8 @@ void GUIFormSpecMenu::drawMenu() } #ifndef HAVE_TOUCHSCREENGUI - if (current_cursor_icon != field.fcursor_icon) + if (field.ftype != f_HyperText && // Handled directly in guiHyperText + current_cursor_icon != field.fcursor_icon) cursor_control->setActiveIcon(field.fcursor_icon); #endif @@ -4235,9 +4234,9 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) || (event.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED) || (event.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED)) { - unsigned int btn_id = event.GUIEvent.Caller->getID(); + s32 caller_id = event.GUIEvent.Caller->getID(); - if (btn_id == 257) { + if (caller_id == 257) { if (m_allowclose) { acceptInput(quit_mode_accept); quitMenu(); @@ -4253,8 +4252,11 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) for (GUIFormSpecMenu::FieldSpec &s : m_fields) { // if its a button, set the send field so // lua knows which button was pressed - if ((s.ftype == f_Button || s.ftype == f_CheckBox) && - s.fid == event.GUIEvent.Caller->getID()) { + + if (caller_id != s.fid) + continue; + + if (s.ftype == f_Button || s.ftype == f_CheckBox) { s.send = true; if (s.is_exit) { if (m_allowclose) { @@ -4270,8 +4272,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) s.send = false; return true; - } else if ((s.ftype == f_DropDown) && - (s.fid == event.GUIEvent.Caller->getID())) { + } else if (s.ftype == f_DropDown) { // only send the changed dropdown for (GUIFormSpecMenu::FieldSpec &s2 : m_fields) { if (s2.ftype == f_DropDown) { @@ -4289,13 +4290,11 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) } } return true; - } else if ((s.ftype == f_ScrollBar) && - (s.fid == event.GUIEvent.Caller->getID())) { + } else if (s.ftype == f_ScrollBar) { s.fdefault = L"Changed"; acceptInput(quit_mode_no); s.fdefault = L""; - } else if ((s.ftype == f_Unknown) && - (s.fid == event.GUIEvent.Caller->getID())) { + } else if (s.ftype == f_Unknown || s.ftype == f_HyperText) { s.send = true; acceptInput(); s.send = false; diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index 7c52336c9..35ee3a2b5 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -49,6 +49,7 @@ typedef enum { f_ScrollBar, f_Box, f_ItemImage, + f_HyperText, f_Unknown } FormspecFieldType; -- cgit v1.2.3