@@ -141,6 +141,8 @@ GUIFormSpecMenu::~GUIFormSpecMenu()
141
141
background_it->drop ();
142
142
for (auto &tooltip_rect_it : m_tooltip_rects)
143
143
tooltip_rect_it.first ->drop ();
144
+ for (auto &clickthrough_it : m_clickthrough_elements)
145
+ clickthrough_it->drop ();
144
146
145
147
delete m_selected_item;
146
148
delete m_form_src;
@@ -742,6 +744,9 @@ void GUIFormSpecMenu::parseImage(parserData* data, const std::string &element)
742
744
e->setNotClipped (style.getBool (StyleSpec::NOCLIP, m_formspec_version < 3 ));
743
745
m_fields.push_back (spec);
744
746
747
+ // images should let events through
748
+ e->grab ();
749
+ m_clickthrough_elements.push_back (e);
745
750
return ;
746
751
}
747
752
@@ -775,6 +780,9 @@ void GUIFormSpecMenu::parseImage(parserData* data, const std::string &element)
775
780
e->setNotClipped (style.getBool (StyleSpec::NOCLIP, m_formspec_version < 3 ));
776
781
m_fields.push_back (spec);
777
782
783
+ // images should let events through
784
+ e->grab ();
785
+ m_clickthrough_elements.push_back (e);
778
786
return ;
779
787
}
780
788
errorstream<< " Invalid image element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -882,7 +890,9 @@ void GUIFormSpecMenu::parseItemImage(parserData* data, const std::string &elemen
882
890
core::rect<s32>(pos, pos + geom), name, m_font, m_client);
883
891
auto style = getStyleForElement (" item_image" , spec.fname );
884
892
e->setNotClipped (style.getBool (StyleSpec::NOCLIP, false ));
885
- e->drop ();
893
+
894
+ // item images should let events through
895
+ m_clickthrough_elements.push_back (e);
886
896
887
897
m_fields.push_back (spec);
888
898
return ;
@@ -1747,6 +1757,10 @@ void GUIFormSpecMenu::parseLabel(parserData* data, const std::string &element)
1747
1757
e->setOverrideColor (style.getColor (StyleSpec::TEXTCOLOR, video::SColor (0xFFFFFFFF )));
1748
1758
1749
1759
m_fields.push_back (spec);
1760
+
1761
+ // labels should let events through
1762
+ e->grab ();
1763
+ m_clickthrough_elements.push_back (e);
1750
1764
}
1751
1765
1752
1766
return ;
@@ -1823,6 +1837,10 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data, const std::string &elemen
1823
1837
e->setOverrideColor (style.getColor (StyleSpec::TEXTCOLOR, video::SColor (0xFFFFFFFF )));
1824
1838
1825
1839
m_fields.push_back (spec);
1840
+
1841
+ // vertlabels should let events through
1842
+ e->grab ();
1843
+ m_clickthrough_elements.push_back (e);
1826
1844
return ;
1827
1845
}
1828
1846
errorstream<< " Invalid vertlabel element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -2745,6 +2763,8 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
2745
2763
background_it->drop ();
2746
2764
for (auto &tooltip_rect_it : m_tooltip_rects)
2747
2765
tooltip_rect_it.first ->drop ();
2766
+ for (auto &clickthrough_it : m_clickthrough_elements)
2767
+ clickthrough_it->drop ();
2748
2768
2749
2769
mydata.size = v2s32 (100 ,100 );
2750
2770
mydata.screensize = screensize;
@@ -2767,6 +2787,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
2767
2787
m_dropdowns.clear ();
2768
2788
theme_by_name.clear ();
2769
2789
theme_by_type.clear ();
2790
+ m_clickthrough_elements.clear ();
2770
2791
2771
2792
m_bgnonfullscreen = true ;
2772
2793
m_bgfullscreen = false ;
@@ -3248,12 +3269,19 @@ void GUIFormSpecMenu::drawMenu()
3248
3269
e->setVisible (false );
3249
3270
}
3250
3271
3272
+ // Some elements are only visible while being drawn
3273
+ for (gui::IGUIElement *e : m_clickthrough_elements)
3274
+ e->setVisible (true );
3275
+
3251
3276
/*
3252
3277
Call base class
3253
3278
(This is where all the drawing happens.)
3254
3279
*/
3255
3280
gui::IGUIElement::draw ();
3256
3281
3282
+ for (gui::IGUIElement *e : m_clickthrough_elements)
3283
+ e->setVisible (false );
3284
+
3257
3285
// Draw hovered item tooltips
3258
3286
for (const std::string &tooltip : m_hovered_item_tooltips) {
3259
3287
showTooltip (utf8_to_wide (tooltip), m_default_tooltip_color,
0 commit comments