Skip to content

Commit 766d160

Browse files
committedMar 11, 2020
guiHyperText: Fix blinky cursor on link hover (#9392)
Change legacy size/position calculations to 'textarea'
1 parent fd4daef commit 766d160

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed
 

Diff for: ‎src/gui/guiFormSpecMenu.cpp

+15-16
Original file line numberDiff line numberDiff line change
@@ -1634,11 +1634,9 @@ void GUIFormSpecMenu::parseHyperText(parserData *data, const std::string &elemen
16341634
pos = getElementBasePos(&v_pos);
16351635
pos -= padding;
16361636

1637-
pos.X += stof(v_pos[0]) * spacing.X;
1638-
pos.Y += stof(v_pos[1]) * spacing.Y + (m_btn_height * 2);
1639-
16401637
geom.X = (stof(v_geom[0]) * spacing.X) - (spacing.X - imgsize.X);
1641-
geom.Y = (stof(v_geom[1]) * imgsize.Y) - (spacing.Y - imgsize.Y);
1638+
geom.Y = (stof(v_geom[1]) * (float)imgsize.Y) - (spacing.Y - imgsize.Y);
1639+
pos.Y += m_btn_height;
16421640
}
16431641

16441642
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
16531651
258 + m_fields.size()
16541652
);
16551653

1656-
spec.ftype = f_Unknown;
1654+
spec.ftype = f_HyperText;
16571655
GUIHyperText *e = new GUIHyperText(spec.flabel.c_str(), Environment, this,
16581656
spec.fid, rect, m_client, m_tsrc);
16591657
e->drop();
@@ -3309,7 +3307,8 @@ void GUIFormSpecMenu::drawMenu()
33093307
}
33103308

33113309
#ifndef HAVE_TOUCHSCREENGUI
3312-
if (current_cursor_icon != field.fcursor_icon)
3310+
if (field.ftype != f_HyperText && // Handled directly in guiHyperText
3311+
current_cursor_icon != field.fcursor_icon)
33133312
cursor_control->setActiveIcon(field.fcursor_icon);
33143313
#endif
33153314

@@ -4235,9 +4234,9 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
42354234
(event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) ||
42364235
(event.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED) ||
42374236
(event.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED)) {
4238-
unsigned int btn_id = event.GUIEvent.Caller->getID();
4237+
s32 caller_id = event.GUIEvent.Caller->getID();
42394238

4240-
if (btn_id == 257) {
4239+
if (caller_id == 257) {
42414240
if (m_allowclose) {
42424241
acceptInput(quit_mode_accept);
42434242
quitMenu();
@@ -4253,8 +4252,11 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
42534252
for (GUIFormSpecMenu::FieldSpec &s : m_fields) {
42544253
// if its a button, set the send field so
42554254
// lua knows which button was pressed
4256-
if ((s.ftype == f_Button || s.ftype == f_CheckBox) &&
4257-
s.fid == event.GUIEvent.Caller->getID()) {
4255+
4256+
if (caller_id != s.fid)
4257+
continue;
4258+
4259+
if (s.ftype == f_Button || s.ftype == f_CheckBox) {
42584260
s.send = true;
42594261
if (s.is_exit) {
42604262
if (m_allowclose) {
@@ -4270,8 +4272,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
42704272
s.send = false;
42714273
return true;
42724274

4273-
} else if ((s.ftype == f_DropDown) &&
4274-
(s.fid == event.GUIEvent.Caller->getID())) {
4275+
} else if (s.ftype == f_DropDown) {
42754276
// only send the changed dropdown
42764277
for (GUIFormSpecMenu::FieldSpec &s2 : m_fields) {
42774278
if (s2.ftype == f_DropDown) {
@@ -4289,13 +4290,11 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
42894290
}
42904291
}
42914292
return true;
4292-
} else if ((s.ftype == f_ScrollBar) &&
4293-
(s.fid == event.GUIEvent.Caller->getID())) {
4293+
} else if (s.ftype == f_ScrollBar) {
42944294
s.fdefault = L"Changed";
42954295
acceptInput(quit_mode_no);
42964296
s.fdefault = L"";
4297-
} else if ((s.ftype == f_Unknown) &&
4298-
(s.fid == event.GUIEvent.Caller->getID())) {
4297+
} else if (s.ftype == f_Unknown || s.ftype == f_HyperText) {
42994298
s.send = true;
43004299
acceptInput();
43014300
s.send = false;

Diff for: ‎src/gui/guiFormSpecMenu.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef enum {
4949
f_ScrollBar,
5050
f_Box,
5151
f_ItemImage,
52+
f_HyperText,
5253
f_Unknown
5354
} FormspecFieldType;
5455

0 commit comments

Comments
 (0)
Please sign in to comment.