LMMS
Loading...
Searching...
No Matches
juce::AlertWindow Class Reference

#include <juce_AlertWindow.h>

Inheritance diagram for juce::AlertWindow:
juce::TopLevelWindow juce::Component juce::MouseListener juce::KeyMappingEditorComponent::ChangeKeyButton::KeyEntryWindow

Classes

struct  LookAndFeelMethods

Public Types

enum  ColourIds { backgroundColourId = 0x1001800 , textColourId = 0x1001810 , outlineColourId = 0x1001820 }
using AlertIconType = MessageBoxIconType
Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }

Public Member Functions

 AlertWindow (const String &title, const String &message, MessageBoxIconType iconType, Component *associatedComponent=nullptr)
 ~AlertWindow () override
MessageBoxIconType getAlertType () const noexcept
void setMessage (const String &message)
void addButton (const String &name, int returnValue, const KeyPress &shortcutKey1=KeyPress(), const KeyPress &shortcutKey2=KeyPress())
int getNumButtons () const
void triggerButtonClick (const String &buttonName)
void setEscapeKeyCancels (bool shouldEscapeKeyCancel)
void addTextEditor (const String &name, const String &initialContents, const String &onScreenLabel=String(), bool isPasswordBox=false)
String getTextEditorContents (const String &nameOfTextEditor) const
TextEditorgetTextEditor (const String &nameOfTextEditor) const
void addComboBox (const String &name, const StringArray &items, const String &onScreenLabel=String())
ComboBoxgetComboBoxComponent (const String &nameOfList) const
void addTextBlock (const String &text)
void addProgressBarComponent (double &progressValue)
void addCustomComponent (Component *component)
int getNumCustomComponents () const
ComponentgetCustomComponent (int index) const
ComponentremoveCustomComponent (int index)
bool containsAnyExtraComponents () const
Public Member Functions inherited from juce::TopLevelWindow
 TopLevelWindow (const String &name, bool addToDesktop)
 ~TopLevelWindow () override
bool isActiveWindow () const noexcept
void centreAroundComponent (Component *componentToCentreAround, int width, int height)
void setDropShadowEnabled (bool useShadow)
bool isDropShadowEnabled () const noexcept
void setUsingNativeTitleBar (bool useNativeTitleBar)
bool isUsingNativeTitleBar () const noexcept
void addToDesktop ()
void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr) override
Public Member Functions inherited from juce::Component
 Component () noexcept
 ~Component () override
 Component (const String &componentName) noexcept
String getName () const noexcept
virtual void setName (const String &newName)
String getComponentID () const noexcept
void setComponentID (const String &newID)
virtual void setVisible (bool shouldBeVisible)
bool isVisible () const noexcept
bool isShowing () const
void removeFromDesktop ()
bool isOnDesktop () const noexcept
ComponentPeergetPeer () const
virtual void minimisationStateChanged (bool isNowMinimised)
void toFront (bool shouldAlsoGainKeyboardFocus)
void toBack ()
void toBehind (Component *other)
void setAlwaysOnTop (bool shouldStayOnTop)
bool isAlwaysOnTop () const noexcept
int getX () const noexcept
int getY () const noexcept
int getWidth () const noexcept
int getHeight () const noexcept
int getRight () const noexcept
Point< intgetPosition () const noexcept
int getBottom () const noexcept
Rectangle< intgetBounds () const noexcept
Rectangle< intgetLocalBounds () const noexcept
Rectangle< intgetBoundsInParent () const noexcept
int getScreenX () const
int getScreenY () const
Point< intgetScreenPosition () const
Rectangle< intgetScreenBounds () const
Point< intgetLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
Rectangle< intgetLocalArea (const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Rectangle< float > getLocalArea (const Component *sourceComponent, Rectangle< float > areaRelativeToSourceComponent) const
Point< intlocalPointToGlobal (Point< int > localPoint) const
Point< float > localPointToGlobal (Point< float > localPoint) const
Rectangle< intlocalAreaToGlobal (Rectangle< int > localArea) const
Rectangle< float > localAreaToGlobal (Rectangle< float > localArea) const
void setTopLeftPosition (int x, int y)
void setTopLeftPosition (Point< int > newTopLeftPosition)
void setTopRightPosition (int x, int y)
void setSize (int newWidth, int newHeight)
void setBounds (int x, int y, int width, int height)
void setBounds (Rectangle< int > newBounds)
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
void setBoundsRelative (Rectangle< float > proportionalArea)
void setBoundsInset (BorderSize< int > borders)
void setBoundsToFit (Rectangle< int > targetArea, Justification justification, bool onlyReduceInSize)
void setCentrePosition (int x, int y)
void setCentrePosition (Point< int > newCentrePosition)
void setCentreRelative (float x, float y)
void centreWithSize (int width, int height)
void setTransform (const AffineTransform &transform)
AffineTransform getTransform () const
bool isTransformed () const noexcept
int proportionOfWidth (float proportion) const noexcept
int proportionOfHeight (float proportion) const noexcept
int getParentWidth () const noexcept
int getParentHeight () const noexcept
Rectangle< intgetParentMonitorArea () const
int getNumChildComponents () const noexcept
ComponentgetChildComponent (int index) const noexcept
int getIndexOfChildComponent (const Component *child) const noexcept
const Array< Component * > & getChildren () const noexcept
ComponentfindChildWithID (StringRef componentID) const noexcept
void addChildComponent (Component *child, int zOrder=-1)
void addChildComponent (Component &child, int zOrder=-1)
void addAndMakeVisible (Component *child, int zOrder=-1)
void addAndMakeVisible (Component &child, int zOrder=-1)
void addChildAndSetID (Component *child, const String &componentID)
void removeChildComponent (Component *childToRemove)
ComponentremoveChildComponent (int childIndexToRemove)
void removeAllChildren ()
void deleteAllChildren ()
ComponentgetParentComponent () const noexcept
template<class TargetClass>
TargetClass * findParentComponentOfClass () const
ComponentgetTopLevelComponent () const noexcept
bool isParentOf (const Component *possibleChild) const noexcept
virtual void childrenChanged ()
virtual bool hitTest (int x, int y)
void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
void getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const noexcept
bool contains (Point< int > localPoint)
bool contains (Point< float > localPoint)
bool reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
bool reallyContains (Point< float > localPoint, bool returnTrueIfWithinAChild)
ComponentgetComponentAt (int x, int y)
ComponentgetComponentAt (Point< int > position)
ComponentgetComponentAt (Point< float > position)
void repaint ()
void repaint (int x, int y, int width, int height)
void repaint (Rectangle< int > area)
void setBufferedToImage (bool shouldBeBuffered)
Image createComponentSnapshot (Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
bool isPaintingUnclipped () const noexcept
void setComponentEffect (ImageEffectFilter *newEffect)
ImageEffectFiltergetComponentEffect () const noexcept
LookAndFeelgetLookAndFeel () const noexcept
void setLookAndFeel (LookAndFeel *newLookAndFeel)
void sendLookAndFeelChange ()
void setOpaque (bool shouldBeOpaque)
bool isOpaque () const noexcept
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
bool isBroughtToFrontOnMouseClick () const noexcept
void setExplicitFocusOrder (int newFocusOrderIndex)
int getExplicitFocusOrder () const
void setFocusContainerType (FocusContainerType containerType) noexcept
bool isFocusContainer () const noexcept
bool isKeyboardFocusContainer () const noexcept
ComponentfindFocusContainer () const
ComponentfindKeyboardFocusContainer () const
void setWantsKeyboardFocus (bool wantsFocus) noexcept
bool getWantsKeyboardFocus () const noexcept
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
bool getMouseClickGrabsKeyboardFocus () const noexcept
void grabKeyboardFocus ()
void giveAwayKeyboardFocus ()
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
void moveKeyboardFocusToSibling (bool moveToNext)
virtual std::unique_ptr< ComponentTraversercreateFocusTraverser ()
virtual std::unique_ptr< ComponentTraversercreateKeyboardFocusTraverser ()
void setHasFocusOutline (bool hasFocusOutline) noexcept
bool hasFocusOutline () const noexcept
bool isEnabled () const noexcept
void setEnabled (bool shouldBeEnabled)
virtual void enablementChanged ()
float getAlpha () const noexcept
void setAlpha (float newAlpha)
virtual void alphaChanged ()
void setMouseCursor (const MouseCursor &cursorType)
virtual MouseCursor getMouseCursor ()
void updateMouseCursor () const
virtual void paintOverChildren (Graphics &g)
void mouseMove (const MouseEvent &event) override
void mouseEnter (const MouseEvent &event) override
void mouseExit (const MouseEvent &event) override
void mouseDown (const MouseEvent &event) override
void mouseDrag (const MouseEvent &event) override
void mouseUp (const MouseEvent &event) override
void mouseDoubleClick (const MouseEvent &event) override
void mouseWheelMove (const MouseEvent &event, const MouseWheelDetails &wheel) override
void mouseMagnify (const MouseEvent &event, float scaleFactor) override
void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept
void addMouseListener (MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
void removeMouseListener (MouseListener *listenerToRemove)
void addKeyListener (KeyListener *newListener)
void removeKeyListener (KeyListener *listenerToRemove)
virtual bool keyStateChanged (bool isKeyDown)
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
virtual void focusGained (FocusChangeType cause)
virtual void focusLost (FocusChangeType cause)
bool isMouseOver (bool includeChildren=false) const
bool isMouseButtonDown (bool includeChildren=false) const
bool isMouseOverOrDragging (bool includeChildren=false) const
Point< intgetMouseXYRelative () const
virtual void resized ()
virtual void moved ()
virtual void childBoundsChanged (Component *child)
virtual void parentSizeChanged ()
virtual void broughtToFront ()
void addComponentListener (ComponentListener *newListener)
void removeComponentListener (ComponentListener *listenerToRemove)
void postCommandMessage (int commandId)
virtual void handleCommandMessage (int commandId)
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
void exitModalState (int returnValue)
bool isCurrentlyModal (bool onlyConsiderForemostModalComponent=true) const noexcept
bool isCurrentlyBlockedByAnotherModalComponent () const
virtual bool canModalEventBeSentToComponent (const Component *targetComponent)
virtual void inputAttemptWhenModal ()
NamedValueSetgetProperties () noexcept
const NamedValueSetgetProperties () const noexcept
Colour findColour (int colourID, bool inheritFromParent=false) const
void setColour (int colourID, Colour newColour)
void removeColour (int colourID)
bool isColourSpecified (int colourID) const
void copyAllExplicitColoursTo (Component &target) const
virtual void colourChanged ()
voidgetWindowHandle () const
PositionergetPositioner () const noexcept
void setPositioner (Positioner *newPositioner)
void setCachedComponentImage (CachedComponentImage *newCachedImage)
CachedComponentImagegetCachedComponentImage () const noexcept
void setViewportIgnoreDragFlag (bool ignoreDrag) noexcept
bool getViewportIgnoreDragFlag () const noexcept
String getTitle () const noexcept
void setTitle (const String &newTitle)
String getDescription () const noexcept
void setDescription (const String &newDescription)
String getHelpText () const noexcept
void setHelpText (const String &newHelpText)
void setAccessible (bool shouldBeAccessible)
bool isAccessible () const noexcept
AccessibilityHandlergetAccessibilityHandler ()
void invalidateAccessibilityHandler ()
void setFocusContainer (bool shouldBeFocusContainer) noexcept
void contains (int, int)=delete
Public Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()=default

Static Public Member Functions

static void JUCE_CALLTYPE showAsync (const MessageBoxOptions &options, ModalComponentManager::Callback *callback)
static void JUCE_CALLTYPE showAsync (const MessageBoxOptions &options, std::function< void(int)> callback)
static void JUCE_CALLTYPE showMessageBoxAsync (MessageBoxIconType iconType, const String &title, const String &message, const String &buttonText=String(), Component *associatedComponent=nullptr, ModalComponentManager::Callback *callback=nullptr)
static bool JUCE_CALLTYPE showOkCancelBox (MessageBoxIconType iconType, const String &title, const String &message, const String &button1Text, const String &button2Text, Component *associatedComponent, ModalComponentManager::Callback *callback)
static int JUCE_CALLTYPE showYesNoCancelBox (MessageBoxIconType iconType, const String &title, const String &message, const String &button1Text, const String &button2Text, const String &button3Text, Component *associatedComponent, ModalComponentManager::Callback *callback)
Static Public Member Functions inherited from juce::TopLevelWindow
static int getNumTopLevelWindows () noexcept
static TopLevelWindowgetTopLevelWindow (int index) noexcept
static TopLevelWindowgetActiveTopLevelWindow () noexcept
Static Public Member Functions inherited from juce::Component
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent (const Component *targetComponent)
static Component *JUCE_CALLTYPE getCurrentlyFocusedComponent () noexcept
static void JUCE_CALLTYPE unfocusAllComponents ()
static void JUCE_CALLTYPE beginDragAutoRepeat (int millisecondsBetweenCallbacks)
static bool JUCE_CALLTYPE isMouseButtonDownAnywhere () noexcept
static int JUCE_CALLTYPE getNumCurrentlyModalComponents () noexcept
static Component *JUCE_CALLTYPE getCurrentlyModalComponent (int index=0) noexcept

Static Public Attributes

static constexpr auto NoIcon = MessageBoxIconType::NoIcon
static constexpr auto QuestionIcon = MessageBoxIconType::QuestionIcon
static constexpr auto WarningIcon = MessageBoxIconType::WarningIcon
static constexpr auto InfoIcon = MessageBoxIconType::InfoIcon

Protected Member Functions

void paint (Graphics &) override
void mouseDown (const MouseEvent &) override
void mouseDrag (const MouseEvent &) override
bool keyPressed (const KeyPress &) override
void lookAndFeelChanged () override
void userTriedToCloseWindow () override
int getDesktopWindowStyleFlags () const override
float getDesktopScaleFactor () const override
Protected Member Functions inherited from juce::TopLevelWindow
virtual void activeWindowStatusChanged ()
void focusOfChildComponentChanged (FocusChangeType) override
void parentHierarchyChanged () override
void recreateDesktopWindow ()
void visibilityChanged () override
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)

Private Member Functions

std::unique_ptr< AccessibilityHandlercreateAccessibilityHandler () override
void exitAlert (Button *button)
void updateLayout (bool onlyIncreaseSize)

Private Attributes

String text
TextLayout textLayout
Label accessibleMessageLabel
MessageBoxIconType alertIconType
ComponentBoundsConstrainer constrainer
ComponentDragger dragger
Rectangle< inttextArea
OwnedArray< TextButtonbuttons
OwnedArray< TextEditortextBoxes
OwnedArray< ComboBoxcomboBoxes
OwnedArray< ProgressBarprogressBars
Array< Component * > customComps
OwnedArray< ComponenttextBlocks
Array< Component * > allComps
StringArray textboxNames
StringArray comboBoxNames
Component *const associatedComponent
bool escapeKeyCancels = true
float desktopScale = 1.0f

Additional Inherited Members

Static Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)

Detailed Description

A window that displays a message and has buttons for the user to react to it.

For simple dialog boxes with just a couple of buttons on them, there are some static methods for running these.

For more complex dialogs, an AlertWindow can be created, then it can have some buttons and components added to it, and its runModalLoop() method is then used to show it. The value returned by runModalLoop() shows which button the user pressed to dismiss the box.

See also
ThreadWithProgressWindow

@tags{GUI}

Member Typedef Documentation

◆ AlertIconType

using juce::AlertWindow::AlertIconType = MessageBoxIconType

Member Enumeration Documentation

◆ ColourIds

enum juce::AlertWindow::ColourIds

A set of colour IDs to use to change the colour of various aspects of the alert box.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
backgroundColourId 

The background colour for the window.

textColourId 

The colour for the text.

outlineColourId 

An optional colour to use to draw a border around the window.

Constructor & Destructor Documentation

◆ AlertWindow()

juce::AlertWindow::AlertWindow ( const String & title,
const String & message,
MessageBoxIconType iconType,
Component * associatedComponent = nullptr )

Creates an AlertWindow.

Parameters
titlethe headline to show at the top of the dialog box
messagea longer, more descriptive message to show underneath the headline
iconTypethe type of icon to display
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.

◆ ~AlertWindow()

juce::AlertWindow::~AlertWindow ( )
override

Destroys the AlertWindow

Member Function Documentation

◆ addButton()

void juce::AlertWindow::addButton ( const String & name,
int returnValue,
const KeyPress & shortcutKey1 = KeyPress(),
const KeyPress & shortcutKey2 = KeyPress() )

Adds a button to the window.

Parameters
namethe text to show on the button
returnValuethe value that should be returned from runModalLoop() if this is the button that the user presses.
shortcutKey1an optional key that can be pressed to trigger this button
shortcutKey2a second optional key that can be pressed to trigger this button

◆ addComboBox()

void juce::AlertWindow::addComboBox ( const String & name,
const StringArray & items,
const String & onScreenLabel = String() )

Adds a drop-down list of choices to the box.

After the box has been shown, the getComboBoxComponent() method can be used to find out which item the user picked.

Parameters
namethe label to use for the drop-down list
itemsthe list of items to show in it
onScreenLabelif this is non-empty, it will be displayed next to the combo-box to label it.
See also
getComboBoxComponent

◆ addCustomComponent()

void juce::AlertWindow::addCustomComponent ( Component * component)

Adds a user-defined component to the dialog box.

Parameters
componentthe component to add - its size should be set up correctly before it is passed in. The caller is responsible for deleting the component later on - the AlertWindow won't delete it.

◆ addProgressBarComponent()

void juce::AlertWindow::addProgressBarComponent ( double & progressValue)

Adds a progress-bar to the window.

Parameters
progressValuea variable that will be repeatedly checked while the dialog box is visible, to see how far the process has got. The value should be in the range 0 to 1.0

◆ addTextBlock()

void juce::AlertWindow::addTextBlock ( const String & text)

Adds a block of text.

This is handy for adding a multi-line note next to a textbox or combo-box, to provide more details about what's going on.

◆ addTextEditor()

void juce::AlertWindow::addTextEditor ( const String & name,
const String & initialContents,
const String & onScreenLabel = String(),
bool isPasswordBox = false )

Adds a textbox to the window for entering strings.

Parameters
namean internal name for the text-box. This is the name to pass to the getTextEditorContents() method to find out what the user typed-in.
initialContentsa string to show in the text box when it's first shown
onScreenLabelif this is non-empty, it will be displayed next to the text-box to label it.
isPasswordBoxif true, the text editor will display asterisks instead of the actual text
See also
getTextEditorContents

◆ containsAnyExtraComponents()

bool juce::AlertWindow::containsAnyExtraComponents ( ) const

Returns true if the window contains any components other than just buttons.

◆ createAccessibilityHandler()

std::unique_ptr< AccessibilityHandler > juce::AlertWindow::createAccessibilityHandler ( )
overrideprivatevirtual

Override this method to return a custom AccessibilityHandler for this component.

The default implementation creates and returns a AccessibilityHandler object with an unspecified role, meaning that it will be visible to accessibility clients but without a specific role, action callbacks or interfaces. To control how accessibility clients see and interact with your component subclass AccessibilityHandler, implement the desired behaviours, and return an instance of it from this method in your component subclass.

The accessibility handler you return here is guaranteed to be destroyed before its Component, so it's safe to store and use a reference back to the Component inside the AccessibilityHandler if necessary.

See also
getAccessibilityHandler

Reimplemented from juce::Component.

◆ exitAlert()

void juce::AlertWindow::exitAlert ( Button * button)
private

◆ getAlertType()

MessageBoxIconType juce::AlertWindow::getAlertType ( ) const
inlinenoexcept

Returns the type of alert icon that was specified when the window was created.

◆ getComboBoxComponent()

ComboBox * juce::AlertWindow::getComboBoxComponent ( const String & nameOfList) const

Returns a drop-down list that was added to the AlertWindow.

Parameters
nameOfListthe name that was passed into the addComboBox() method when creating the drop-down
Returns
the ComboBox component, or nullptr if none was found for the given name.

◆ getCustomComponent()

Component * juce::AlertWindow::getCustomComponent ( int index) const

Returns one of the custom components in the dialog box.

Parameters
indexa value 0 to (getNumCustomComponents() - 1). Out-of-range indexes will return nullptr
See also
getNumCustomComponents, addCustomComponent

◆ getDesktopScaleFactor()

float juce::AlertWindow::getDesktopScaleFactor ( ) const
inlineoverrideprotectedvirtual

Returns the default scale factor to use for this component when it is placed on the desktop. The default implementation of this method just returns the value from Desktop::getGlobalScaleFactor(), but it can be overridden if a particular component has different requirements. The method only used if this component is added to the desktop - it has no effect for child components.

Reimplemented from juce::Component.

◆ getDesktopWindowStyleFlags()

int juce::AlertWindow::getDesktopWindowStyleFlags ( ) const
overrideprotectedvirtual

Reimplemented from juce::TopLevelWindow.

◆ getNumButtons()

int juce::AlertWindow::getNumButtons ( ) const

Returns the number of buttons that the window currently has.

◆ getNumCustomComponents()

int juce::AlertWindow::getNumCustomComponents ( ) const

Returns the number of custom components in the dialog box.

See also
getCustomComponent, addCustomComponent

◆ getTextEditor()

TextEditor * juce::AlertWindow::getTextEditor ( const String & nameOfTextEditor) const

Returns a pointer to a textbox that was added with addTextEditor().

◆ getTextEditorContents()

String juce::AlertWindow::getTextEditorContents ( const String & nameOfTextEditor) const

Returns the contents of a named textbox.

After showing an AlertWindow that contains a text editor, this can be used to find out what the user has typed into it.

Parameters
nameOfTextEditorthe name of the text box that you're interested in
See also
addTextEditor

◆ keyPressed()

bool juce::AlertWindow::keyPressed ( const KeyPress & key)
overrideprotectedvirtual

Called when a key is pressed.

When a key is pressed, the component that has the keyboard focus will have this method called. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this.

If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, the key will be passed to any KeyListeners that have been registered with this component. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on.

The default implementation of this method does nothing and returns false.

See also
keyStateChanged, getCurrentlyFocusedComponent, addKeyListener

Reimplemented from juce::Component.

Reimplemented in juce::KeyMappingEditorComponent::ChangeKeyButton::KeyEntryWindow.

◆ lookAndFeelChanged()

void juce::AlertWindow::lookAndFeelChanged ( )
overrideprotectedvirtual

Called to let the component react to a change in the look-and-feel setting.

When the look-and-feel is changed for a component, this will be called in all its child components, recursively.

It can also be triggered manually by the sendLookAndFeelChange() method, in case an application uses a LookAndFeel class that might have changed internally.

See also
sendLookAndFeelChange, getLookAndFeel

Reimplemented from juce::Component.

◆ mouseDown()

void juce::AlertWindow::mouseDown ( const MouseEvent & event)
overrideprotectedvirtual

Called when a mouse button is pressed.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseUp, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::MouseListener.

◆ mouseDrag()

void juce::AlertWindow::mouseDrag ( const MouseEvent & event)
overrideprotectedvirtual

Called when the mouse is moved while a button is held down.

When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseUp, mouseMove, contains, setDragRepeatInterval

Reimplemented from juce::MouseListener.

◆ paint()

void juce::AlertWindow::paint ( Graphics & g)
overrideprotectedvirtual

Components can override this method to draw their content.

The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.

Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.

If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In JUCE (and almost all modern UI frameworks), you never redraw something synchronously.

You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().

Parameters
gthe graphics context that must be used to do the drawing operations.
See also
repaint, paintOverChildren, Graphics

Reimplemented from juce::Component.

◆ removeCustomComponent()

Component * juce::AlertWindow::removeCustomComponent ( int index)

Removes one of the custom components in the dialog box. Note that this won't delete it, it just removes the component from the window

Parameters
indexa value 0 to (getNumCustomComponents() - 1). Out-of-range indexes will return nullptr
Returns
the component that was removed (or null)
See also
getNumCustomComponents, addCustomComponent

◆ setEscapeKeyCancels()

void juce::AlertWindow::setEscapeKeyCancels ( bool shouldEscapeKeyCancel)

If set to true and the window contains no buttons, then pressing the escape key will make the alert cancel its modal state. By default this setting is true - turn it off if you don't want the box to respond to the escape key. Note that it is ignored if you have any buttons, and in that case you should give the buttons appropriate keypresses to trigger cancelling if you want to.

◆ setMessage()

void juce::AlertWindow::setMessage ( const String & message)

Changes the dialog box's message.

This will also resize the window to fit the new message if required.

◆ showAsync() [1/2]

void juce::AlertWindow::showAsync ( const MessageBoxOptions & options,
ModalComponentManager::Callback * callback )
static

Shows a dialog box using the specified options.

The box will be displayed and placed into a modal state, but this method will return immediately, and the callback will be invoked later when the user dismisses the box.

Parameters
Optionsthe options to use when creating the dialog.
callbackif this is non-null, the callback will receive a call to its modalStateFinished() when the box is dismissed with the index of the button that was clicked as its argument. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted before it gets called.
See also
MessageBoxOptions

◆ showAsync() [2/2]

void juce::AlertWindow::showAsync ( const MessageBoxOptions & options,
std::function< void(int)> callback )
static

Shows a dialog box using the specified options.

The box will be displayed and placed into a modal state, but this method will return immediately, and the callback will be invoked later when the user dismisses the box.

Parameters
Optionsthe options to use when creating the dialog.
callbackif this is non-null, the callback will be called when the box is dismissed with the index of the button that was clicked as its argument.
See also
MessageBoxOptions

◆ showMessageBoxAsync()

void juce::AlertWindow::showMessageBoxAsync ( MessageBoxIconType iconType,
const String & title,
const String & message,
const String & buttonText = String(),
Component * associatedComponent = nullptr,
ModalComponentManager::Callback * callback = nullptr )
static

Shows a dialog box that just has a message and a single button to get rid of it.

The box will be displayed and placed into a modal state, but this method will return immediately, and if a callback was supplied, it will be invoked later when the user dismisses the box.

Parameters
iconTypethe type of icon to show
titlethe headline to show at the top of the box
messagea longer, more descriptive message to show underneath the headline
buttonTextthe text to show in the button - if this string is empty, the default string "OK" (or a localised version) will be used.
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.
callbackif this is non-null, the callback will receive a call to its modalStateFinished() when the box is dismissed. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted before it gets called.

◆ showOkCancelBox()

bool juce::AlertWindow::showOkCancelBox ( MessageBoxIconType iconType,
const String & title,
const String & message,
const String & button1Text,
const String & button2Text,
Component * associatedComponent,
ModalComponentManager::Callback * callback )
static

Shows a dialog box with two buttons.

Ideal for ok/cancel or yes/no choices. The return key can also be used to trigger the first button, and the escape key for the second button.

If the callback parameter is null, the box is shown modally, and the method will block until the user has clicked the button (or pressed the escape or return keys). If the callback parameter is non-null, the box will be displayed and placed into a modal state, but this method will return immediately, and the callback will be invoked later when the user dismisses the box.

Parameters
iconTypethe type of icon to show
titlethe headline to show at the top of the box
messagea longer, more descriptive message to show underneath the headline
button1Textthe text to show in the first button - if this string is empty, the default string "OK" (or a localised version of it) will be used.
button2Textthe text to show in the second button - if this string is empty, the default string "cancel" (or a localised version of it) will be used.
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.
callbackif this is non-null, the menu will be launched asynchronously, returning immediately, and the callback will receive a call to its modalStateFinished() when the box is dismissed, with its parameter being 1 if the ok button was pressed, or 0 for cancel. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted before it gets called.
Returns
true if button 1 was clicked, false if it was button 2. If the callback parameter is not null, the method always returns false, and the user's choice is delivered later by the callback.

◆ showYesNoCancelBox()

int juce::AlertWindow::showYesNoCancelBox ( MessageBoxIconType iconType,
const String & title,
const String & message,
const String & button1Text,
const String & button2Text,
const String & button3Text,
Component * associatedComponent,
ModalComponentManager::Callback * callback )
static

Shows a dialog box with three buttons.

Ideal for yes/no/cancel boxes.

The escape key can be used to trigger the third button.

If the callback parameter is null, the box is shown modally, and the method will block until the user has clicked the button (or pressed the escape or return keys). If the callback parameter is non-null, the box will be displayed and placed into a modal state, but this method will return immediately, and the callback will be invoked later when the user dismisses the box.

Parameters
iconTypethe type of icon to show
titlethe headline to show at the top of the box
messagea longer, more descriptive message to show underneath the headline
button1Textthe text to show in the first button - if an empty string, then "yes" will be used (or a localised version of it)
button2Textthe text to show in the first button - if an empty string, then "no" will be used (or a localised version of it)
button3Textthe text to show in the first button - if an empty string, then "cancel" will be used (or a localised version of it)
associatedComponentif this is non-null, it specifies the component that the alert window should be associated with. Depending on the look and feel, this might be used for positioning of the alert window.
callbackif this is non-null, the menu will be launched asynchronously, returning immediately, and the callback will receive a call to its modalStateFinished() when the box is dismissed, with its parameter being 1 if the "yes" button was pressed, 2 for the "no" button, or 0 if it was cancelled. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted before it gets called.
Returns
If the callback parameter has been set, this returns 0. Otherwise, it returns one of the following values:
  • 0 if the third button was pressed (normally used for 'cancel')
  • 1 if the first button was pressed (normally used for 'yes')
  • 2 if the middle button was pressed (normally used for 'no')

◆ triggerButtonClick()

void juce::AlertWindow::triggerButtonClick ( const String & buttonName)

Invokes a click of one of the buttons.

◆ updateLayout()

void juce::AlertWindow::updateLayout ( bool onlyIncreaseSize)
private

◆ userTriedToCloseWindow()

void juce::AlertWindow::userTriedToCloseWindow ( )
overrideprotectedvirtual

For components on the desktop, this is called if the system wants to close the window.

This is a signal that either the user or the system wants the window to close. The default implementation of this method will trigger an assertion to warn you that your component should do something about it, but you can override this to ignore the event if you want.

Reimplemented from juce::Component.

Member Data Documentation

◆ accessibleMessageLabel

Label juce::AlertWindow::accessibleMessageLabel
private

◆ alertIconType

MessageBoxIconType juce::AlertWindow::alertIconType
private

◆ allComps

Array<Component*> juce::AlertWindow::allComps
private

◆ associatedComponent

Component* const juce::AlertWindow::associatedComponent
private

◆ buttons

OwnedArray<TextButton> juce::AlertWindow::buttons
private

◆ comboBoxes

OwnedArray<ComboBox> juce::AlertWindow::comboBoxes
private

◆ comboBoxNames

StringArray juce::AlertWindow::comboBoxNames
private

◆ constrainer

ComponentBoundsConstrainer juce::AlertWindow::constrainer
private

◆ customComps

Array<Component*> juce::AlertWindow::customComps
private

◆ desktopScale

float juce::AlertWindow::desktopScale = 1.0f
private

◆ dragger

ComponentDragger juce::AlertWindow::dragger
private

◆ escapeKeyCancels

bool juce::AlertWindow::escapeKeyCancels = true
private

◆ InfoIcon

auto juce::AlertWindow::InfoIcon = MessageBoxIconType::InfoIcon
staticconstexpr

◆ NoIcon

auto juce::AlertWindow::NoIcon = MessageBoxIconType::NoIcon
staticconstexpr

◆ progressBars

OwnedArray<ProgressBar> juce::AlertWindow::progressBars
private

◆ QuestionIcon

auto juce::AlertWindow::QuestionIcon = MessageBoxIconType::QuestionIcon
staticconstexpr

◆ text

String juce::AlertWindow::text
private

◆ textArea

Rectangle<int> juce::AlertWindow::textArea
private

◆ textBlocks

OwnedArray<Component> juce::AlertWindow::textBlocks
private

◆ textBoxes

OwnedArray<TextEditor> juce::AlertWindow::textBoxes
private

◆ textboxNames

StringArray juce::AlertWindow::textboxNames
private

◆ textLayout

TextLayout juce::AlertWindow::textLayout
private

◆ WarningIcon

auto juce::AlertWindow::WarningIcon = MessageBoxIconType::WarningIcon
staticconstexpr

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