Skip to content

Commit 2f32b42

Browse files
authored
Update richtext.lua to add richtext.remove() (#65)
* Update richtext.lua to add richtext.remove() Added function richtext.remove(). It's trivial to loop over the words table and do it yourself, but it looks a bit cluttered when you are attempting to delete multiple rich text tables. * Update README.md Add description of function richtext.remove() * Update richtext.lua Replace table.getn with #
1 parent f94a23b commit 2f32b42

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ Call this function when a click/touch has been detected and your text contains w
286286
* `consumed` (boolean) - True if any word was clicked.
287287

288288

289+
### richtext.remove(words)
290+
Removes all gui text nodes created by `richtext.create()`.
291+
292+
**PARAMETERS**
293+
* `words` (table) - Table of words, as received from a call to `richtext.create()`.
294+
295+
289296
### richtext.ALIGN_LEFT
290297
Left-align text. The words of a line starts at the specified position (see `richtext.create` settings above).
291298

richtext/richtext.lua

+10
Original file line numberDiff line numberDiff line change
@@ -634,5 +634,15 @@ function M.characters(word)
634634
return chars
635635
end
636636

637+
---Removes the gui nodes created by rich text
638+
function M.remove(words)
639+
assert(words)
640+
641+
local num = #words
642+
for i=1,num do
643+
gui.delete_node(words[i].node)
644+
end
645+
end
646+
637647

638648
return M

0 commit comments

Comments
 (0)