Luart
Comprehensive Windows framework to develop in Lua
modules > ui > fontdialog

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

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.

Return value

If a font selection has been made, this function returns four values which correspond to the characteristics of the selected font : If the user clicked on the Cancel button, this function returns nil.

Example


local ui = require "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