RichTextLabel.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="RichTextLabel" inherits="Control" category="Core" version="3.1.2">
  3. <brief_description>
  4. Label that displays rich text.
  5. </brief_description>
  6. <description>
  7. Rich text can contain custom text, fonts, images and some basic formatting. The label manages these as an internal tag stack. It also adapts itself to given width/heights.
  8. Note that assignments to [member bbcode_text] clear the tag stack and reconstruct it from the property's contents. Any edits made to [member bbcode_text] will erase previous edits made from other manual sources such as [method append_bbcode] and the [code]push_*[/code] / [method pop] methods.
  9. </description>
  10. <tutorials>
  11. <link>https://docs.godotengine.org/en/3.1/tutorials/gui/bbcode_in_richtextlabel.html</link>
  12. </tutorials>
  13. <methods>
  14. <method name="add_image">
  15. <return type="void">
  16. </return>
  17. <argument index="0" name="image" type="Texture">
  18. </argument>
  19. <description>
  20. Adds an image's opening and closing tags to the tag stack.
  21. </description>
  22. </method>
  23. <method name="add_text">
  24. <return type="void">
  25. </return>
  26. <argument index="0" name="text" type="String">
  27. </argument>
  28. <description>
  29. Adds raw non-bbcode-parsed text to the tag stack.
  30. </description>
  31. </method>
  32. <method name="append_bbcode">
  33. <return type="int" enum="Error">
  34. </return>
  35. <argument index="0" name="bbcode" type="String">
  36. </argument>
  37. <description>
  38. Parses [code]bbcode[/code] and adds tags to the tag stack as needed. Returns the result of the parsing, [constant @GlobalScope.OK] if successful.
  39. </description>
  40. </method>
  41. <method name="clear">
  42. <return type="void">
  43. </return>
  44. <description>
  45. Clears the tag stack and sets [member bbcode_text] to an empty string.
  46. </description>
  47. </method>
  48. <method name="get_content_height">
  49. <return type="int">
  50. </return>
  51. <description>
  52. Returns the height of the content.
  53. </description>
  54. </method>
  55. <method name="get_line_count" qualifiers="const">
  56. <return type="int">
  57. </return>
  58. <description>
  59. Returns the total number of newlines in the tag stack's text tags. Considers wrapped text as one line.
  60. </description>
  61. </method>
  62. <method name="get_total_character_count" qualifiers="const">
  63. <return type="int">
  64. </return>
  65. <description>
  66. Returns the total number of characters from text tags. Does not include bbcodes.
  67. </description>
  68. </method>
  69. <method name="get_v_scroll">
  70. <return type="VScrollBar">
  71. </return>
  72. <description>
  73. Returns the vertical scrollbar.
  74. </description>
  75. </method>
  76. <method name="get_visible_line_count" qualifiers="const">
  77. <return type="int">
  78. </return>
  79. <description>
  80. Returns the number of visible lines.
  81. </description>
  82. </method>
  83. <method name="newline">
  84. <return type="void">
  85. </return>
  86. <description>
  87. Adds a newline tag to the tag stack.
  88. </description>
  89. </method>
  90. <method name="parse_bbcode">
  91. <return type="int" enum="Error">
  92. </return>
  93. <argument index="0" name="bbcode" type="String">
  94. </argument>
  95. <description>
  96. The assignment version of [method append_bbcode]. Clears the tag stack and inserts the new content. Returns [constant @GlobalScope.OK] if parses [code]bbcode[/code] successfully.
  97. </description>
  98. </method>
  99. <method name="pop">
  100. <return type="void">
  101. </return>
  102. <description>
  103. Terminates the current tag. Use after [code]push_*[/code] methods to close bbcodes manually. Does not need to follow [code]add_*[/code] methods.
  104. </description>
  105. </method>
  106. <method name="push_align">
  107. <return type="void">
  108. </return>
  109. <argument index="0" name="align" type="int" enum="RichTextLabel.Align">
  110. </argument>
  111. <description>
  112. Adds an alignment tag based on the given [code]align[/code] value. See [enum Align] for possible values.
  113. </description>
  114. </method>
  115. <method name="push_cell">
  116. <return type="void">
  117. </return>
  118. <description>
  119. Adds a [code][cell][/code] tag to the tag stack. Must be inside a [code][table][/code] tag. See [method push_table] for details.
  120. </description>
  121. </method>
  122. <method name="push_color">
  123. <return type="void">
  124. </return>
  125. <argument index="0" name="color" type="Color">
  126. </argument>
  127. <description>
  128. Adds a [code][color][/code] tag to the tag stack.
  129. </description>
  130. </method>
  131. <method name="push_font">
  132. <return type="void">
  133. </return>
  134. <argument index="0" name="font" type="Font">
  135. </argument>
  136. <description>
  137. Adds a [code][font][/code] tag to the tag stack. Overrides default fonts for its duration.
  138. </description>
  139. </method>
  140. <method name="push_indent">
  141. <return type="void">
  142. </return>
  143. <argument index="0" name="level" type="int">
  144. </argument>
  145. <description>
  146. Adds an [code][indent][/code] tag to the tag stack. Multiplies "level" by current tab_size to determine new margin length.
  147. </description>
  148. </method>
  149. <method name="push_list">
  150. <return type="void">
  151. </return>
  152. <argument index="0" name="type" type="int" enum="RichTextLabel.ListType">
  153. </argument>
  154. <description>
  155. Adds a list tag to the tag stack. Similar to the bbcodes [code][ol][/code] or [code][ul][/code], but supports more list types. Not fully implemented!
  156. </description>
  157. </method>
  158. <method name="push_meta">
  159. <return type="void">
  160. </return>
  161. <argument index="0" name="data" type="Variant">
  162. </argument>
  163. <description>
  164. Adds a meta tag to the tag stack. Similar to the bbcode [code][url=something]{text}[/url][/code], but supports non-[String] metadata types.
  165. </description>
  166. </method>
  167. <method name="push_strikethrough">
  168. <return type="void">
  169. </return>
  170. <description>
  171. Adds a [code][s][/code] tag to the tag stack.
  172. </description>
  173. </method>
  174. <method name="push_table">
  175. <return type="void">
  176. </return>
  177. <argument index="0" name="columns" type="int">
  178. </argument>
  179. <description>
  180. Adds a [code][table=columns][/code] tag to the tag stack.
  181. </description>
  182. </method>
  183. <method name="push_underline">
  184. <return type="void">
  185. </return>
  186. <description>
  187. Adds a [code][u][/code] tag to the tag stack.
  188. </description>
  189. </method>
  190. <method name="remove_line">
  191. <return type="bool">
  192. </return>
  193. <argument index="0" name="line" type="int">
  194. </argument>
  195. <description>
  196. Removes a line of content from the label. Returns [code]true[/code] if the line exists.
  197. </description>
  198. </method>
  199. <method name="scroll_to_line">
  200. <return type="void">
  201. </return>
  202. <argument index="0" name="line" type="int">
  203. </argument>
  204. <description>
  205. Scrolls the window's top line to match [code]line[/code].
  206. </description>
  207. </method>
  208. <method name="set_table_column_expand">
  209. <return type="void">
  210. </return>
  211. <argument index="0" name="column" type="int">
  212. </argument>
  213. <argument index="1" name="expand" type="bool">
  214. </argument>
  215. <argument index="2" name="ratio" type="int">
  216. </argument>
  217. <description>
  218. Edits the selected columns expansion options. If [code]expand[/code] is [code]true[/code], the column expands in proportion to its expansion ratio versus the other columns' ratios.
  219. For example, 2 columns with ratios 3 and 4 plus 70 pixels in available width would expand 30 and 40 pixels, respectively.
  220. Columns with a [code]false[/code] expand will not contribute to the total ratio.
  221. </description>
  222. </method>
  223. </methods>
  224. <members>
  225. <member name="bbcode_enabled" type="bool" setter="set_use_bbcode" getter="is_using_bbcode">
  226. If [code]true[/code], the label uses BBCode formatting. Default value: [code]false[/code].
  227. </member>
  228. <member name="bbcode_text" type="String" setter="set_bbcode" getter="get_bbcode">
  229. The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited.
  230. </member>
  231. <member name="meta_underlined" type="bool" setter="set_meta_underline" getter="is_meta_underlined">
  232. If [code]true[/code], the label underlines meta tags such as [code][url]{text}[/url][/code]. Default value: [code]true[/code].
  233. </member>
  234. <member name="override_selected_font_color" type="bool" setter="set_override_selected_font_color" getter="is_overriding_selected_font_color">
  235. If [code]true[/code], the label uses the custom font color. Default value: [code]false[/code].
  236. </member>
  237. <member name="percent_visible" type="float" setter="set_percent_visible" getter="get_percent_visible">
  238. The text's visibility, as a [float] between 0.0 and 1.0.
  239. </member>
  240. <member name="scroll_active" type="bool" setter="set_scroll_active" getter="is_scroll_active">
  241. If [code]true[/code], the scrollbar is visible. Does not block scrolling completely. See [method scroll_to_line]. Default value: [code]true[/code].
  242. </member>
  243. <member name="scroll_following" type="bool" setter="set_scroll_follow" getter="is_scroll_following">
  244. If [code]true[/code], the window scrolls down to display new content automatically. Default value: [code]false[/code].
  245. </member>
  246. <member name="selection_enabled" type="bool" setter="set_selection_enabled" getter="is_selection_enabled">
  247. If [code]true[/code], the label allows text selection.
  248. </member>
  249. <member name="tab_size" type="int" setter="set_tab_size" getter="get_tab_size">
  250. The number of spaces associated with a single tab length. Does not affect "\t" in text tags, only indent tags.
  251. </member>
  252. <member name="text" type="String" setter="set_text" getter="get_text">
  253. The raw text of the label.
  254. When set, clears the tag stack and adds a raw text tag to the top of it. Does not parse bbcodes. Does not modify [member bbcode_text].
  255. </member>
  256. <member name="visible_characters" type="int" setter="set_visible_characters" getter="get_visible_characters">
  257. The restricted number of characters to display in the label.
  258. </member>
  259. </members>
  260. <signals>
  261. <signal name="meta_clicked">
  262. <argument index="0" name="meta" type="Nil">
  263. </argument>
  264. <description>
  265. Triggered when the user clicks on content between [code][url][/code] tags. If the meta is defined in text, e.g. [code][url={"data"="hi"}]hi[/url][/code], then the parameter for this signal will be a [String] type. If a particular type or an object is desired, the [method push_meta] method must be used to manually insert the data into the tag stack.
  266. </description>
  267. </signal>
  268. <signal name="meta_hover_ended">
  269. <argument index="0" name="meta" type="Nil">
  270. </argument>
  271. <description>
  272. Triggers when the mouse exits a meta tag.
  273. </description>
  274. </signal>
  275. <signal name="meta_hover_started">
  276. <argument index="0" name="meta" type="Nil">
  277. </argument>
  278. <description>
  279. Triggers when the mouse enters a meta tag.
  280. </description>
  281. </signal>
  282. </signals>
  283. <constants>
  284. <constant name="ALIGN_LEFT" value="0" enum="Align">
  285. </constant>
  286. <constant name="ALIGN_CENTER" value="1" enum="Align">
  287. </constant>
  288. <constant name="ALIGN_RIGHT" value="2" enum="Align">
  289. </constant>
  290. <constant name="ALIGN_FILL" value="3" enum="Align">
  291. </constant>
  292. <constant name="LIST_NUMBERS" value="0" enum="ListType">
  293. </constant>
  294. <constant name="LIST_LETTERS" value="1" enum="ListType">
  295. </constant>
  296. <constant name="LIST_DOTS" value="2" enum="ListType">
  297. </constant>
  298. <constant name="ITEM_FRAME" value="0" enum="ItemType">
  299. </constant>
  300. <constant name="ITEM_TEXT" value="1" enum="ItemType">
  301. </constant>
  302. <constant name="ITEM_IMAGE" value="2" enum="ItemType">
  303. </constant>
  304. <constant name="ITEM_NEWLINE" value="3" enum="ItemType">
  305. </constant>
  306. <constant name="ITEM_FONT" value="4" enum="ItemType">
  307. </constant>
  308. <constant name="ITEM_COLOR" value="5" enum="ItemType">
  309. </constant>
  310. <constant name="ITEM_UNDERLINE" value="6" enum="ItemType">
  311. </constant>
  312. <constant name="ITEM_STRIKETHROUGH" value="7" enum="ItemType">
  313. </constant>
  314. <constant name="ITEM_ALIGN" value="8" enum="ItemType">
  315. </constant>
  316. <constant name="ITEM_INDENT" value="9" enum="ItemType">
  317. </constant>
  318. <constant name="ITEM_LIST" value="10" enum="ItemType">
  319. </constant>
  320. <constant name="ITEM_TABLE" value="11" enum="ItemType">
  321. </constant>
  322. <constant name="ITEM_META" value="12" enum="ItemType">
  323. </constant>
  324. </constants>
  325. <theme_items>
  326. <theme_item name="bold_font" type="Font">
  327. </theme_item>
  328. <theme_item name="bold_italics_font" type="Font">
  329. </theme_item>
  330. <theme_item name="default_color" type="Color">
  331. </theme_item>
  332. <theme_item name="focus" type="StyleBox">
  333. </theme_item>
  334. <theme_item name="font_color_selected" type="Color">
  335. </theme_item>
  336. <theme_item name="font_color_shadow" type="Color">
  337. </theme_item>
  338. <theme_item name="italics_font" type="Font">
  339. </theme_item>
  340. <theme_item name="line_separation" type="int">
  341. </theme_item>
  342. <theme_item name="mono_font" type="Font">
  343. </theme_item>
  344. <theme_item name="normal" type="StyleBox">
  345. </theme_item>
  346. <theme_item name="normal_font" type="Font">
  347. </theme_item>
  348. <theme_item name="selection_color" type="Color">
  349. </theme_item>
  350. <theme_item name="shadow_as_outline" type="int">
  351. </theme_item>
  352. <theme_item name="shadow_offset_x" type="int">
  353. </theme_item>
  354. <theme_item name="shadow_offset_y" type="int">
  355. </theme_item>
  356. <theme_item name="table_hseparation" type="int">
  357. </theme_item>
  358. <theme_item name="table_vseparation" type="int">
  359. </theme_item>
  360. </theme_items>
  361. </class>