mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 19:12:24 -05:00
[Tree] Allow disabling auto generated tooltip for TreeItem
This commit is contained in:
parent
893bbdfde8
commit
77549dd1f3
3 changed files with 21 additions and 1 deletions
|
@ -341,6 +341,9 @@
|
|||
<member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="true">
|
||||
If [code]true[/code], allows navigating the [Tree] with letter keys through incremental search.
|
||||
</member>
|
||||
<member name="auto_tooltip" type="bool" setter="set_auto_tooltip" getter="is_auto_tooltip_enabled" default="true">
|
||||
If [code]true[/code], tree items with no tooltip assigned display their text as their tooltip. See also [method TreeItem.get_tooltip_text] and [method TreeItem.get_button_tooltip_text].
|
||||
</member>
|
||||
<member name="clip_contents" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" />
|
||||
<member name="column_titles_visible" type="bool" setter="set_column_titles_visible" getter="are_column_titles_visible" default="false">
|
||||
If [code]true[/code], column titles are visible.
|
||||
|
|
|
@ -5750,7 +5750,7 @@ String Tree::get_tooltip(const Point2 &p_pos) const {
|
|||
|
||||
if (it) {
|
||||
const String item_tooltip = it->get_tooltip_text(col);
|
||||
if (item_tooltip.is_empty()) {
|
||||
if (enable_auto_tooltip && item_tooltip.is_empty()) {
|
||||
return it->get_text(col);
|
||||
}
|
||||
return item_tooltip;
|
||||
|
@ -5832,6 +5832,14 @@ bool Tree::get_allow_search() const {
|
|||
return allow_search;
|
||||
}
|
||||
|
||||
void Tree::set_auto_tooltip(bool p_enable) {
|
||||
enable_auto_tooltip = p_enable;
|
||||
}
|
||||
|
||||
bool Tree::is_auto_tooltip_enabled() const {
|
||||
return enable_auto_tooltip;
|
||||
}
|
||||
|
||||
void Tree::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("clear"), &Tree::clear);
|
||||
ClassDB::bind_method(D_METHOD("create_item", "parent", "index"), &Tree::create_item, DEFVAL(Variant()), DEFVAL(-1));
|
||||
|
@ -5915,6 +5923,9 @@ void Tree::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_allow_search", "allow"), &Tree::set_allow_search);
|
||||
ClassDB::bind_method(D_METHOD("get_allow_search"), &Tree::get_allow_search);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_auto_tooltip", "enable"), &Tree::set_auto_tooltip);
|
||||
ClassDB::bind_method(D_METHOD("is_auto_tooltip_enabled"), &Tree::is_auto_tooltip_enabled);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "columns"), "set_columns", "get_columns");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "column_titles_visible"), "set_column_titles_visible", "are_column_titles_visible");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_reselect"), "set_allow_reselect", "get_allow_reselect");
|
||||
|
@ -5927,6 +5938,7 @@ void Tree::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::INT, "select_mode", PROPERTY_HINT_ENUM, "Single,Row,Multi"), "set_select_mode", "get_select_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_enabled"), "set_h_scroll_enabled", "is_h_scroll_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_enabled"), "set_v_scroll_enabled", "is_v_scroll_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_tooltip"), "set_auto_tooltip", "is_auto_tooltip_enabled");
|
||||
|
||||
ADD_SIGNAL(MethodInfo("item_selected"));
|
||||
ADD_SIGNAL(MethodInfo("cell_selected"));
|
||||
|
|
|
@ -699,6 +699,8 @@ private:
|
|||
|
||||
bool enable_recursive_folding = true;
|
||||
|
||||
bool enable_auto_tooltip = true;
|
||||
|
||||
void _determine_hovered_item();
|
||||
|
||||
int _count_selected_items(TreeItem *p_from) const;
|
||||
|
@ -830,6 +832,9 @@ public:
|
|||
void set_allow_search(bool p_allow);
|
||||
bool get_allow_search() const;
|
||||
|
||||
void set_auto_tooltip(bool p_enable);
|
||||
bool is_auto_tooltip_enabled() const;
|
||||
|
||||
Size2 get_minimum_size() const override;
|
||||
|
||||
Tree();
|
||||
|
|
Loading…
Add table
Reference in a new issue