guiHyperText: Fix blinky cursor on link hover (#9392)
authorSmallJoker <mk939@ymail.com>
Tue, 11 Feb 2020 18:53:09 +0000 (19:53 +0100)
committerSmallJoker <mk939@ymail.com>
Wed, 11 Mar 2020 18:09:50 +0000 (19:09 +0100)
Change legacy size/position calculations to 'textarea'

src/gui/guiFormSpecMenu.cpp
src/gui/guiFormSpecMenu.h

index 45eb0d17caffc58a22ea2f0f665ebf8dbee9ff8e..b96f536642067c96963faa75fcb5941ed8fca38d 100644 (file)
@@ -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<s32> rect = core::rect<s32>(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;
index 7c52336c93c2eacd3b674a4d67cf61ff9257ac24..35ee3a2b5a91dfe27bb1c29a585bcdbce99e78ed 100644 (file)
@@ -49,6 +49,7 @@ typedef enum {
        f_ScrollBar,
        f_Box,
        f_ItemImage,
+       f_HyperText,
        f_Unknown
 } FormspecFieldType;