Loading...
Searching...
No Matches
juce::MessageBoxButtonOptions Class Reference

Detailed Description

Class that holds configuration information about the action buttons displayed in a message box.


The documentation for this class was generated from the following file:

Public Member Functions

 MessageBoxButtonOptions (String textIn, int codeIn)
 Sets the text and result code for this action.
MessageBoxButtonOptions & setRole (MessageBoxButtonRole roleIn)
 Sets the role of this button.
MessageBoxButtonOptions withRole (MessageBoxButtonRole roleIn) const
 Like setRole(), but returns a copy of this object with the new state applied.
MessageBoxButtonOptions & setPreferredAction (bool shouldBeDefault=true)
 Sets whether this button is the default/primary action of the dialog, usually highlighted and selected with the 'return' key on the keyboard.
MessageBoxButtonOptions withPreferredAction (bool shouldBeDefault=true) const
 Like setPreferredAction(), but returns a copy of this object with the new state applied.
String getText () const
 Returns the text corresponding to this action.
int getCode () const
 Returns the result code of this action.
MessageBoxButtonRole getRole () const
 Returns the role of this action.
bool isPreferredAction () const
 Returns true if this is the preferred action, or false otherwise.

Constructors and Destructors

◆ MessageBoxButtonOptions()

juce::MessageBoxButtonOptions::MessageBoxButtonOptions ( String textIn,
int codeIn )
inline

Sets the text and result code for this action.

Result codes should be unique for each action within the same message box.

Referenced by setPreferredAction(), setRole(), withPreferredAction(), and withRole().

Member Functions

◆ setRole()

MessageBoxButtonOptions & juce::MessageBoxButtonOptions::setRole ( MessageBoxButtonRole roleIn)
inline

Sets the role of this button.

If unspecified, the button will have the 'normal' role. Within a given message box, a maximum of one button may have the 'destroy' role, and a maximum of one button may have the 'cancel' role.

The button with the 'cancel' role, if present, will be positioned as follows in a native message box:

  • macOS: bottom of the stack of buttons, or leftmost, depending on layout
  • Android: leftmost
  • Windows: rightmost
  • iOS: bottom of the stack of buttons, or leftmost, depending on layout

You will get the best result across all platforms by setting both the preferred action and the cancel role.

References MessageBoxButtonOptions().

◆ withRole()

MessageBoxButtonOptions juce::MessageBoxButtonOptions::withRole ( MessageBoxButtonRole roleIn) const
inlinenodiscard

Like setRole(), but returns a copy of this object with the new state applied.

References MessageBoxButtonOptions().

◆ setPreferredAction()

MessageBoxButtonOptions & juce::MessageBoxButtonOptions::setPreferredAction ( bool shouldBeDefault = true)
inline

Sets whether this button is the default/primary action of the dialog, usually highlighted and selected with the 'return' key on the keyboard.

If no action is specified as preferred, then the first button added to the dialog without the 'cancel' role will be treated as the preferred action.

The preferred action (either explicit or implicit) will be positioned as follows in a native message box:

  • macOS: top of the stack of buttons, or rightmost, depending on layout
  • Android: rightmost
  • Windows: leftmost
  • iOS: top of the stack of buttons (three buttons), or rightmost (two buttons). The cancel role takes precedence, so if the layout has two buttons and one button has the cancel role, the cancel button will be leftmost.

You will get the best result across all platforms by setting both the preferred action and the cancel role.

References MessageBoxButtonOptions().

◆ withPreferredAction()

MessageBoxButtonOptions juce::MessageBoxButtonOptions::withPreferredAction ( bool shouldBeDefault = true) const
inlinenodiscard

Like setPreferredAction(), but returns a copy of this object with the new state applied.

References MessageBoxButtonOptions().

◆ getText()

String juce::MessageBoxButtonOptions::getText ( ) const
inline

Returns the text corresponding to this action.

◆ getCode()

int juce::MessageBoxButtonOptions::getCode ( ) const
inline

Returns the result code of this action.

◆ getRole()

MessageBoxButtonRole juce::MessageBoxButtonOptions::getRole ( ) const
inline

Returns the role of this action.

◆ isPreferredAction()

bool juce::MessageBoxButtonOptions::isPreferredAction ( ) const
inline

Returns true if this is the preferred action, or false otherwise.