wxErlang

Reference Manual

Version 2.0

Table of Contents

wxNotificationMessage

Module

wxNotificationMessage

Module Summary

Functions for wxNotificationMessage class

Description

This class allows showing the user a message non intrusively.

Currently it is implemented natively for Windows, macOS, GTK and uses generic toast notifications under the other platforms. It's not recommended but wxGenericNotificationMessage can be used instead of the native ones. This might make sense if your application requires features not available in the native implementation.

Notice that this class is not a window and so doesn't derive from wxWindow.

Platform Notes

Par: Up to Windows 8 balloon notifications are displayed from an icon in the notification area of the taskbar. If your application uses a wxTaskBarIcon you should call UseTaskBarIcon() (not implemented in wx) to ensure that only one icon is shown in the notification area. Windows 10 displays all notifications as popup toasts. To suppress the additional icon in the notification area on Windows 10 and for toast notification support on Windows 8 it is recommended to call MSWUseToasts() (not implemented in wx) before showing the first notification message.

Par: The macOS implementation uses Notification Center to display native notifications. In order to use actions your notifications must use the alert style. This can be enabled by the user in system settings or by setting the NSUserNotificationAlertStyle value in Info.plist to alert. Please note that the user always has the option to change the notification style.

Since: 2.9.0

This class is derived (and can use functions) from: wxEvtHandler

wxWidgets docs: wxNotificationMessage

Default constructor, use setParent/2, setTitle/2 and setMessage/2 to initialize the object before showing it.

new(Title) -> wxNotificationMessage()

Types

new(Title, Options :: [Option]) -> wxNotificationMessage()

Types

Option =
    {message, unicode:chardata()} |
    {parent, wxWindow:wxWindow()} |
    {flags, integer()}

Create a notification object with the given attributes.

See setTitle/2, setMessage/2, setParent/2 and setFlags/2 for the description of the corresponding parameters.

destroy(This :: wxNotificationMessage()) -> ok

Destructor does not hide the notification.

The notification can continue to be shown even after the C++ object was destroyed, call close/1 explicitly if it needs to be hidden.

addAction(This, Actionid) -> boolean()

Types

Actionid = integer()
addAction(This, Actionid, Options :: [Option]) -> boolean()

Types

Actionid = integer()
Option = {label, unicode:chardata()}

Add an action to the notification.

If supported by the implementation this are usually buttons in the notification selectable by the user.

Return: false if the current implementation or OS version does not support actions in notifications.

Since: 3.1.0

close(This) -> boolean()

Hides the notification.

Returns true if it was hidden or false if it couldn't be done (e.g. on some systems automatically hidden notifications can't be hidden manually).

setFlags(This, Flags) -> ok

Types

Flags = integer()

This parameter can be currently used to specify the icon to show in the notification.

Valid values are wxICON_INFORMATION, wxICON_WARNING and wxICON_ERROR (notice that wxICON_QUESTION is not allowed here). Some implementations of this class may not support the icons.

See: setIcon/2

setIcon(This, Icon) -> ok

Specify a custom icon to be displayed in the notification.

Some implementations of this class may not support custom icons.

See: setFlags/2

Since: 3.1.0

setMessage(This, Message) -> ok

Set the main text of the notification.

This should be a more detailed description than the title but still limited to reasonable length (not more than 256 characters).

setParent(This, Parent) -> ok

Set the parent for this notification: the notification will be associated with the top level parent of this window or, if this method is not called, with the main application window by default.

setTitle(This, Title) -> ok

Set the title, it must be a concise string (not more than 64 characters), use setMessage/2 to give the user more details.

show(This) -> boolean()
show(This, Options :: [Option]) -> boolean()

Types

Option = {timeout, integer()}

Show the notification to the user and hides it after timeout seconds are elapsed.

Special values Timeout_Auto and Timeout_Never can be used here, notice that you shouldn't rely on timeout being exactly respected because the current platform may only support default timeout value and also because the user may be able to close the notification.

Note: When using native notifications in wxGTK, the timeout is ignored for the notifications with wxICON_WARNING or wxICON_ERROR flags, they always remain shown unless they're explicitly hidden by the user, i.e. behave as if Timeout_Auto were given.

Return: false if an error occurred.