Changing this property may erase the current text if the provided string don't contains Rich Text Formatted text.
Edit.richtext read/write property
Get or set the Edit text content as a string, with Rich Text Formatting.
To get the text without formatting, use the Edit.text property instead.
Example
local ui = require "ui"
-- create a simple window
local win = ui.Window("Edit.rtf sample", "fixed", 400, 260)
local button = ui.Button(win, "Toggle richtext", 2, 10)
local rtf = [[{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}{\f1\fnil\fprq2\fcharset0 Biondi;}}{\colortbl ;\red255\green0\blue0;}{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20\par\cf1\f1 hello\cf0\f0 \ul world !\par}]]
local edit = ui.Edit(win, rtf, button.x + button.width + 4, button.y)
local function update_status()
win:status("Edit.rtf = "..tostring(edit.rtf))
end
function button:onClick()
-- empty the Edit before setting the Edit.richtext property
edit.rtf = not edit.rtf
edit.richtext = rtf
update_status()
end
update_status()
-- update user interface
ui.run(win):wait()