mirror of
https://github.com/minetest/minetest.git
synced 2024-11-26 17:43:45 +01:00
guiHyperText: Fix blinky cursor on link hover (#9392)
Change legacy size/position calculations to 'textarea'
This commit is contained in:
parent
fd4daefb29
commit
766d160ffb
@ -1634,11 +1634,9 @@ void GUIFormSpecMenu::parseHyperText(parserData *data, const std::string &elemen
|
|||||||
pos = getElementBasePos(&v_pos);
|
pos = getElementBasePos(&v_pos);
|
||||||
pos -= padding;
|
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.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);
|
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()
|
258 + m_fields.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
spec.ftype = f_Unknown;
|
spec.ftype = f_HyperText;
|
||||||
GUIHyperText *e = new GUIHyperText(spec.flabel.c_str(), Environment, this,
|
GUIHyperText *e = new GUIHyperText(spec.flabel.c_str(), Environment, this,
|
||||||
spec.fid, rect, m_client, m_tsrc);
|
spec.fid, rect, m_client, m_tsrc);
|
||||||
e->drop();
|
e->drop();
|
||||||
@ -3309,7 +3307,8 @@ void GUIFormSpecMenu::drawMenu()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_TOUCHSCREENGUI
|
#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);
|
cursor_control->setActiveIcon(field.fcursor_icon);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4235,9 +4234,9 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
(event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) ||
|
(event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) ||
|
||||||
(event.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED) ||
|
(event.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED) ||
|
||||||
(event.GUIEvent.EventType == gui::EGET_SCROLL_BAR_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) {
|
if (m_allowclose) {
|
||||||
acceptInput(quit_mode_accept);
|
acceptInput(quit_mode_accept);
|
||||||
quitMenu();
|
quitMenu();
|
||||||
@ -4253,8 +4252,11 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
for (GUIFormSpecMenu::FieldSpec &s : m_fields) {
|
for (GUIFormSpecMenu::FieldSpec &s : m_fields) {
|
||||||
// if its a button, set the send field so
|
// if its a button, set the send field so
|
||||||
// lua knows which button was pressed
|
// 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;
|
s.send = true;
|
||||||
if (s.is_exit) {
|
if (s.is_exit) {
|
||||||
if (m_allowclose) {
|
if (m_allowclose) {
|
||||||
@ -4270,8 +4272,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
s.send = false;
|
s.send = false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if ((s.ftype == f_DropDown) &&
|
} else if (s.ftype == f_DropDown) {
|
||||||
(s.fid == event.GUIEvent.Caller->getID())) {
|
|
||||||
// only send the changed dropdown
|
// only send the changed dropdown
|
||||||
for (GUIFormSpecMenu::FieldSpec &s2 : m_fields) {
|
for (GUIFormSpecMenu::FieldSpec &s2 : m_fields) {
|
||||||
if (s2.ftype == f_DropDown) {
|
if (s2.ftype == f_DropDown) {
|
||||||
@ -4289,13 +4290,11 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if ((s.ftype == f_ScrollBar) &&
|
} else if (s.ftype == f_ScrollBar) {
|
||||||
(s.fid == event.GUIEvent.Caller->getID())) {
|
|
||||||
s.fdefault = L"Changed";
|
s.fdefault = L"Changed";
|
||||||
acceptInput(quit_mode_no);
|
acceptInput(quit_mode_no);
|
||||||
s.fdefault = L"";
|
s.fdefault = L"";
|
||||||
} else if ((s.ftype == f_Unknown) &&
|
} else if (s.ftype == f_Unknown || s.ftype == f_HyperText) {
|
||||||
(s.fid == event.GUIEvent.Caller->getID())) {
|
|
||||||
s.send = true;
|
s.send = true;
|
||||||
acceptInput();
|
acceptInput();
|
||||||
s.send = false;
|
s.send = false;
|
||||||
|
@ -49,6 +49,7 @@ typedef enum {
|
|||||||
f_ScrollBar,
|
f_ScrollBar,
|
||||||
f_Box,
|
f_Box,
|
||||||
f_ItemImage,
|
f_ItemImage,
|
||||||
|
f_HyperText,
|
||||||
f_Unknown
|
f_Unknown
|
||||||
} FormspecFieldType;
|
} FormspecFieldType;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user