Ability to disable item list tooltip, issue 6240
(cherry picked from commit 62a968b1c6
)
This commit is contained in:
parent
aae720e488
commit
0aad82e921
2 changed files with 22 additions and 0 deletions
|
@ -40,6 +40,7 @@ void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool
|
|||
item.selectable=p_selectable;
|
||||
item.selected=false;
|
||||
item.disabled=false;
|
||||
item.tooltip_enabled=true;
|
||||
item.custom_bg=Color(0,0,0,0);
|
||||
items.push_back(item);
|
||||
|
||||
|
@ -57,6 +58,7 @@ void ItemList::add_icon_item(const Ref<Texture>& p_item,bool p_selectable){
|
|||
item.selectable=p_selectable;
|
||||
item.selected=false;
|
||||
item.disabled=false;
|
||||
item.tooltip_enabled=true;
|
||||
item.custom_bg=Color(0,0,0,0);
|
||||
items.push_back(item);
|
||||
|
||||
|
@ -82,6 +84,16 @@ String ItemList::get_item_text(int p_idx) const{
|
|||
|
||||
}
|
||||
|
||||
void ItemList::set_item_tooltip_enabled(int p_idx, const bool p_enabled) {
|
||||
ERR_FAIL_INDEX(p_idx,items.size());
|
||||
items[p_idx].tooltip_enabled = p_enabled;
|
||||
}
|
||||
|
||||
bool ItemList::is_item_tooltip_enabled(int p_idx) const {
|
||||
ERR_FAIL_INDEX_V(p_idx,items.size(), false);
|
||||
return items[p_idx].tooltip_enabled;
|
||||
}
|
||||
|
||||
void ItemList::set_item_tooltip(int p_idx,const String& p_tooltip){
|
||||
|
||||
ERR_FAIL_INDEX(p_idx,items.size());
|
||||
|
@ -1198,6 +1210,9 @@ String ItemList::get_tooltip(const Point2& p_pos) const {
|
|||
int closest = get_item_at_pos(p_pos);
|
||||
|
||||
if (closest!=-1) {
|
||||
if (!items[closest].tooltip_enabled) {
|
||||
return "";
|
||||
}
|
||||
if (items[closest].tooltip!="") {
|
||||
return items[closest].tooltip;
|
||||
}
|
||||
|
@ -1294,6 +1309,9 @@ void ItemList::_bind_methods(){
|
|||
ObjectTypeDB::bind_method(_MD("set_item_custom_bg_color","idx","custom_bg_color"),&ItemList::set_item_custom_bg_color);
|
||||
ObjectTypeDB::bind_method(_MD("get_item_custom_bg_color","idx"),&ItemList::get_item_custom_bg_color);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
|
||||
ObjectTypeDB::bind_method(_MD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
|
||||
ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
bool selectable;
|
||||
bool selected;
|
||||
bool disabled;
|
||||
bool tooltip_enabled;
|
||||
Variant metadata;
|
||||
String tooltip;
|
||||
Color custom_bg;
|
||||
|
@ -135,6 +136,9 @@ public:
|
|||
void set_item_tag_icon(int p_idx,const Ref<Texture>& p_tag_icon);
|
||||
Ref<Texture> get_item_tag_icon(int p_idx) const;
|
||||
|
||||
void set_item_tooltip_enabled(int p_idx, const bool p_enabled);
|
||||
bool is_item_tooltip_enabled(int p_idx) const;
|
||||
|
||||
void set_item_tooltip(int p_idx,const String& p_tooltip);
|
||||
String get_item_tooltip(int p_idx) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue