Skip to main content

Rich Edits

Last Updated Time: 09/26/2023

See \02_demo\test_project\res\content\maps\ui_demo.fmap for details on the example in this documentation.

Overview​

The Rich Edit is used to receive user input and supports multi-line editing and part of HTML syntax.

Click Rich Edit to get the focus (a cursor will flash in the editing bar at this time), and Rich Edit will not get user input until it gets the focus. Click the area outside Rich Edit will make it lose the focus and thus fail to get user input.

HTML Text Format-font​

font PropertyDescription
faceSpecify the font style.
colorSpecify the font color.
sizeSpecify the font size.
boldBold font.
italicItalic font.
underlineAdd underlines to fonts.

font-face Font Style​

RichEdit_Left.Text = nx_widestr("
<font>RichEdit</font>
")

RichEdit_Right.Text = nx_widestr("
<font face=\"Default30I\">RichEdit</font>
")

Note

The configuration of the font style Default30I is as follows (See Font for details):

image-20230922150838011

font-color Font Color​

RichEdit_Left.Text = nx_widestr("
<font>RichEdit</font>
")

RichEdit_Right.Text = nx_widestr("
<font color=\"#8431bb\">RichEdit</font>
")

font-size Font Size​

RichEdit_Left.Text = nx_widestr("
<font>RichEdit</font>
")

RichEdit_Right.Text = nx_widestr("
<font size=\"35\">RichEdit</font>
")

font-bold Bold Font​

RichEdit_Left.Text = nx_widestr("
<font>RichEdit</font>
")

RichEdit_Right.Text = nx_widestr("
<font bold=\"true\">RichEdit</font>
")

font-italic Italic Font​

RichEdit_Left.Text = nx_widestr("
<font>RichEdit</font>
")

RichEdit_Right.Text = nx_widestr("
<font italic=\"true\">RichEdit</font>
")

font-underline Adding Underlines to Fonts​

RichEdit_Left.Text = nx_widestr("
<font>RichEdit</font>
")

RichEdit_Right.Text = nx_widestr("
<font underline=\"true\">RichEdit</font>
")

font-Example​

RichEdit_Left.Text = nx_widestr("
<font>RichEdit_1 RichEdit_2</font><br/>
<font>RichEdit_3 RichEdit_4</font><br/>
<font>RichEdit_5 RichEdit_6</font>
")

RichEdit_Right.Text = nx_widestr("
<font face=\"Default15W\">RichEdit_1</font> <font face=\"Default15W\" color=\"#8431bb\">RichEdit_2</font><br/>
<font size=\"20\" bold=\"true\">RichEdit_3</font><br/>
<font italic=\"true\">RichEdit_4/<font><br/>
<font underline=\"true\">RichEdit_5 RichEdit_6</font>
<font face=\"Default15W\" color=\"#8431bb\" size=\"20\" bold=\"true\" italic=\"true\" underline=\"true\">RichEdit_7</font>
")

Rich Edit Properties​

PropertyDescription
TextContent displayed in the current Rich Edit.
Font ColorUsed to display the font color of the control.
Floating Hint TextPrompt text displayed when the mouse is hovering over the control.
HTML Tag Format TextWhether the control supports parsing HTML.

Rich Edit Events​

image-20230920163238306

Callback NameCallback Function
on_get_focusThe callback when getting the focus by clicking.
on_lost_focusThe callback when losing the focus by clicking.
on_changedThe callback when the input content changes.
on_enterThe callback when pressing the Enter key.

Lua Script Example​

self.Text = "Edit"
self.AlwaysVScroll = true

function on_rich_edit_enter(self)
local str=nx_string(self.Text)
nx_msgbox(str)
end