Changing this property from
false
to true
may erase the current text if it's not a valid Rich Text Formatted text.Edit.rtf read/write property
Determines if the Edit control uses plain text (the default) or RTF formatted text, a true value meaning that the Edit uses Rich Text Format.
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()