diff options
author | Jean Jung <jean.jung@rocketmail.com> | 2016-06-29 12:43:51 -0300 |
---|---|---|
committer | Jean Jung <jean.jung@rocketmail.com> | 2016-06-29 12:43:51 -0300 |
commit | aeb5365e841d610a3b9a0fde0520238909c25c49 (patch) | |
tree | 43c429299d8d93577f8b1722363b3d5533a1dbaa | |
parent | ea108bed7941725b1da2e0e28d7c8dc23f4fff70 (diff) |
Adding support to get the raw text without formatting information from a RichTextLabel.
-rw-r--r-- | doc/base/classes.xml | 19 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 19 | ||||
-rw-r--r-- | scene/gui/rich_text_label.h | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 4b5c424d4b..9ac5e0f566 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -21631,6 +21631,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Return [i]true[/i] if the "node" argument is a direct or indirect child of the current node, otherwise return [i]false[/i]. </description> </method> + <method name="is_displayed_folded" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> <method name="is_fixed_processing" qualifiers="const"> <return type="bool"> </return> @@ -21750,6 +21756,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Replace a node in a scene by a given one. Subscriptions that pass through this node will be lost. </description> </method> + <method name="set_display_folded"> + <argument index="0" name="fold" type="bool"> + </argument> + <description> + </description> + </method> <method name="set_filename"> <argument index="0" name="filename" type="String"> </argument> @@ -31508,6 +31520,13 @@ A similar effect may be achieved moving this node's descendants. <description> </description> </method> + <method name="get_text"> + <return type="String"> + </return> + <description> + Returns the raw text, stripping out the formatting information. + </description> + </method> <method name="get_total_character_count" qualifiers="const"> <return type="int"> </return> diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 786ce27a0c..6d7ac0e7f3 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1941,11 +1941,30 @@ bool RichTextLabel::is_using_bbcode() const { return use_bbcode; } + +String RichTextLabel::get_text() { + String text = ""; + Item *it = main; + while (it) { + if (it->type == ITEM_TEXT) { + ItemText *t = static_cast<ItemText*>(it); + text += t->text; + } else if (it->type == ITEM_NEWLINE) { + text += "\n"; + } else if (it->type == ITEM_INDENT) { + text += "\t"; + } + it=_get_next_item(it,true); + } + return text; +} + void RichTextLabel::_bind_methods() { ObjectTypeDB::bind_method(_MD("_input_event"),&RichTextLabel::_input_event); ObjectTypeDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed); + ObjectTypeDB::bind_method(_MD("get_text"),&RichTextLabel::get_text); ObjectTypeDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text); ObjectTypeDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image); ObjectTypeDB::bind_method(_MD("newline"),&RichTextLabel::add_newline); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 635fe87ad4..5147905a0e 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -280,6 +280,7 @@ protected: public: + String get_text(); void add_text(const String& p_text); void add_image(const Ref<Texture>& p_image); void add_newline(); |