ToastMessageInterface Class Reference

#include <toastmessage.h>

Inheritance diagram for ToastMessageInterface:

Detailed Description

Represents a toast message that can be shown to the user. A toast message is a small, transient notification typically anchored to the main application window, displaying a short text and an optional action button.

Instances of this interface act as a stable identity for coalescing: if Show is called again on the same instance (or on a copy of the same reference) while the previous toast triggered by it is still visible, the two occurrences are merged into a single toast instead of showing two separate ones. The occurrence count passed to the ToastMessageFormatter reflects how many times Show has been called for this instance since the toast was last dismissed.

Note
Instantiating this interface does not show anything by itself; nothing is displayed until Show is called.
To keep coalescing several related calls together, retain the same ToastMessageRef and call Show on it repeatedly, rather than creating a new reference for every occurrence.

Public Types

enum class  ICON_TYPE {
  NONE ,
  WARNING ,
  ERROR
}
 

Public Member Functions

MAXON_METHOD Result< void > SetMessageFormatter (ToastMessageFormatter &&formatter)
 
MAXON_METHOD Result< void > SetActionButton (const String &actionButtonText, ToastActionDelegate &&actionButtonDelegate)
 
enum maxon::ToastMessageInterface::ICON_TYPE MAXON_ENUM_LIST_CLASS (ICON_TYPE)
 
MAXON_METHOD void SetIconType (ICON_TYPE iconType)
 
MAXON_METHOD Result< void > Show ()
 

Private Member Functions

 MAXON_INTERFACE (ToastMessageInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.toastmessage")
 

Member Enumeration Documentation

◆ ICON_TYPE

enum ICON_TYPE
strong

The type of icon to show in the toast message.

Enumerator
NONE 

No icon is shown.

WARNING 

A warning message.

ERROR 

An error message.

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( ToastMessageInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.toastmessage"   
)
private

◆ SetMessageFormatter()

MAXON_METHOD Result<void> SetMessageFormatter ( ToastMessageFormatter &&  formatter)

Sets the formatter used to compute the displayed text of the toast message. This must be set before calling Show, since the text of the toast (for any occurrence count) is always derived from this formatter.

Parameters
[in]formatterThe formatter to use. The caller owns the pointed the moved-from delegate.
Returns
OK on success, or an error if the formatter is invalid.

◆ SetActionButton()

MAXON_METHOD Result<void> SetActionButton ( const String &  actionButtonText,
ToastActionDelegate &&  actionButtonDelegate 
)

Sets the text and delegate of the toast message's action button. Setting an action button is optional; if never called, the toast is shown without one. If this toast is coalesced with a later occurrence, the action button text and delegate set by the most recent call are the ones retained and used.

Parameters
[in]actionButtonTextThe text of the action button.
[in]actionButtonDelegateThe delegate invoked when the action button is pressed. The caller owns the pointed the moved-from delegate.
Returns
OK on success.

◆ MAXON_ENUM_LIST_CLASS()

enum maxon::ToastMessageInterface::ICON_TYPE MAXON_ENUM_LIST_CLASS ( ICON_TYPE  )

◆ SetIconType()

MAXON_METHOD void SetIconType ( ICON_TYPE  iconType)

Sets the type of icon shown alongside the toast message. Setting an icon is optional; if never called, the toast is shown without one (ICON_TYPE::NONE). If this toast is coalesced with a later occurrence, the icon type set by the most recent call is the one retained and used.

Parameters
[in]iconTypeThe icon type to display. See ICON_TYPE.

◆ Show()

MAXON_METHOD Result<void> Show ( )

Shows the toast message. If a toast previously shown by this same instance is still visible, this occurrence is coalesced into it: the occurrence count is incremented, the message text is recomputed via the formatter set with SetMessageFormatter, and the toast's visible-time is extended. Otherwise, a new toast is shown with an occurrence count of 1.

Note
SetMessageFormatter must have been called with a valid formatter before this is called.
Returns
OK on success, or an error if the toast could not be shown (for example, if no message formatter has been set).