RichTextLabel.xml 13 KB

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