Other functions
NWG also has a few functions that are not located under the UI object.
NWG has a function to display a message box and 3 functions that wrap it for more common purpose.
The
message
function takes a
MessageParams
ref as argument and creates a message box. Once the user as selected a value, it returns a
MessageChoice
enum.
simple_message
and
error_message
use predefined buttons and icon and let the user specify the title and the message from the function.
fatal_message
looks just like
error_message
but it panics before returning.
let params = nwg::constants::MessageParams{
title: "Hello",
content: "Hello World",
buttons: nwg::constants::MessageButtons::OkCancel,
icons: nwg::constants::MessageIcons::Warning
};
let answer1 = nwg::message(¶ms);
let answer2 = nwg::simple_message("Hello", "Hello World");
let answer3 = nwg::error_message("Hello", "Hello World");
nwg::fatal_message("Goodbye", "Goodbye World");
Once the Ui initialization is done, the threads needs to listen to the system events. In order to do that the
dispatch_events
function must be used. The method will dispatch the events to
every instanced UI. As soon as a main window is closed (
exit_on_close
set to true) or if
nwg::exit
is called, the function will return.
The exit function breaks the
dispatch_events
loop. It can be used to close a thread or forcefully close an application.