ui.fontdialog([widget], [color])function

Displays a dialog box for the user to choose a Windows system font.

Parameters

[widget]

An optional widget whose font will initialize dialog's fields.
If an Edit widget is provided, the current selection font is used to initialize dialog's fields.

[color]

An optional number representing a RGB color value, to initialize the dialog color field.

Notes

  • The dialog box only uses the current Windows system theme

Return value

If a font selection has been made, this function returns four values which correspond to the characteristics of the selected font :
  • The font name as a string.
  • The font size as a number.
  • The font style as a table with boolean fields "italic", "underline", "striked", "bold", "thin", "heavy".
  • The font color as a number.
If the user clicked on the Cancel button, this function returns nil.

Example

--! luart-extensions import ui -- open a dialog to choose a font local name, size, style, color = ui.fontdialog() -- check if a font have been choosen if name ~= " " then -- output font characteristics local msg = "Font name : "..name.."\nFont size : "..size.."\nFont color : "..string.format("%X", color).."\nFont style :" for k, v in pairs(style) do if v then msg = msg.." ["..k.."]" end end ui.info(msg) end