openshot-audio  0.1.2
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
juce::Button Class Referenceabstract

#include <juce_gui_basics.h>

Inheritance diagram for juce::Button:
juce::Component juce::SettableTooltipClient juce::MouseListener juce::TooltipClient juce::ArrowButton juce::DrawableButton juce::HyperlinkButton juce::ImageButton juce::KeyMappingEditorComponent::ChangeKeyButton juce::LookAndFeel_V2::GlassWindowButton juce::LookAndFeel_V3_DocumentWindowButton juce::ScrollBar::ScrollbarButton juce::ShapeButton juce::TabBarButton juce::TextButton juce::ToggleButton juce::ToolbarItemComponent

Classes

class  CallbackHelper
 
class  Listener
 
struct  LookAndFeelMethods
 

Public Types

enum  ConnectedEdgeFlags { ConnectedOnLeft = 1, ConnectedOnRight = 2, ConnectedOnTop = 4, ConnectedOnBottom = 8 }
 
enum  ButtonState { buttonNormal, buttonOver, buttonDown }
 
- Public Types inherited from juce::Component
enum  FocusChangeType { focusChangedByMouseClick, focusChangedByTabKey, focusChangedDirectly }
 

Public Member Functions

virtual ~Button ()
 
void setButtonText (const String &newText)
 
const StringgetButtonText () const
 
bool isDown () const noexcept
 
bool isOver () const noexcept
 
void setToggleState (bool shouldBeOn, NotificationType notification)
 
bool getToggleState () const noexcept
 
ValuegetToggleStateValue () noexcept
 
void setClickingTogglesState (bool shouldAutoToggleOnClick) noexcept
 
bool getClickingTogglesState () const noexcept
 
void setRadioGroupId (int newGroupId, NotificationType notification=sendNotification)
 
int getRadioGroupId () const noexcept
 
void addListener (Listener *newListener)
 
void removeListener (Listener *listener)
 
virtual void triggerClick ()
 
void setCommandToTrigger (ApplicationCommandManager *commandManagerToUse, CommandID commandID, bool generateTooltip)
 
CommandID getCommandID () const noexcept
 
void addShortcut (const KeyPress &)
 
void clearShortcuts ()
 
bool isRegisteredForShortcut (const KeyPress &) const
 
void setRepeatSpeed (int initialDelayInMillisecs, int repeatDelayInMillisecs, int minimumDelayInMillisecs=-1) noexcept
 
void setTriggeredOnMouseDown (bool isTriggeredOnMouseDown) noexcept
 
uint32 getMillisecondsSinceButtonDown () const noexcept
 
void setTooltip (const String &newTooltip) override
 
void setConnectedEdges (int connectedEdgeFlags)
 
int getConnectedEdgeFlags () const noexcept
 
bool isConnectedOnLeft () const noexcept
 
bool isConnectedOnRight () const noexcept
 
bool isConnectedOnTop () const noexcept
 
bool isConnectedOnBottom () const noexcept
 
void setState (ButtonState newState)
 
ButtonState getState () const noexcept
 
 JUCE_DEPRECATED (void setToggleState(bool, bool))
 
- Public Member Functions inherited from juce::Component
 Component () noexcept
 
virtual ~Component ()
 
 Component (const String &componentName) noexcept
 
const StringgetName () const noexcept
 
virtual void setName (const String &newName)
 
const StringgetComponentID () const noexcept
 
void setComponentID (const String &newID)
 
virtual void setVisible (bool shouldBeVisible)
 
bool isVisible () const noexcept
 
bool isShowing () const
 
virtual void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
 
void removeFromDesktop ()
 
bool isOnDesktop () const noexcept
 
ComponentPeergetPeer () const
 
virtual void userTriedToCloseWindow ()
 
virtual void minimisationStateChanged (bool isNowMinimised)
 
virtual float getDesktopScaleFactor () const
 
void toFront (bool shouldAlsoGainFocus)
 
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
 
const Rectangle< int > & getBounds () 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, const Rectangle< int > &areaRelativeToSourceComponent) const
 
Point< intlocalPointToGlobal (Point< int > localPoint) const
 
Point< float > localPointToGlobal (Point< float > localPoint) const
 
Rectangle< intlocalAreaToGlobal (const Rectangle< int > &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 (const Rectangle< int > &newBounds)
 
void setBounds (const RelativeRectangle &newBounds)
 
void setBounds (const String &newBoundsExpression)
 
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
 
void setBoundsInset (const BorderSize< int > &borders)
 
void setBoundsToFit (int x, int y, int width, int height, Justification justification, bool onlyReduceInSize)
 
void setCentrePosition (int x, int y)
 
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
 
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 reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
 
ComponentgetComponentAt (int x, int y)
 
ComponentgetComponentAt (Point< int > position)
 
void repaint ()
 
void repaint (int x, int y, int width, int height)
 
void repaint (const Rectangle< int > &area)
 
void setBufferedToImage (bool shouldBeBuffered)
 
Image createComponentSnapshot (const Rectangle< int > &areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
 
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
 
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
 
void setComponentEffect (ImageEffectFilter *newEffect)
 
ImageEffectFiltergetComponentEffect () const noexcept
 
LookAndFeelgetLookAndFeel () const noexcept
 
void setLookAndFeel (LookAndFeel *newLookAndFeel)
 
virtual void lookAndFeelChanged ()
 
void sendLookAndFeelChange ()
 
void setOpaque (bool shouldBeOpaque)
 
bool isOpaque () const noexcept
 
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
 
bool isBroughtToFrontOnMouseClick () const noexcept
 
void setWantsKeyboardFocus (bool wantsFocus) noexcept
 
bool getWantsKeyboardFocus () const noexcept
 
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
 
bool getMouseClickGrabsKeyboardFocus () const noexcept
 
void grabKeyboardFocus ()
 
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
 
void moveKeyboardFocusToSibling (bool moveToNext)
 
virtual KeyboardFocusTraversercreateFocusTraverser ()
 
int getExplicitFocusOrder () const
 
void setExplicitFocusOrder (int newFocusOrderIndex)
 
void setFocusContainer (bool shouldBeFocusContainer) noexcept
 
bool isFocusContainer () const noexcept
 
bool isEnabled () const noexcept
 
void setEnabled (bool shouldBeEnabled)
 
void setAlpha (float newAlpha)
 
float getAlpha () const
 
void setMouseCursor (const MouseCursor &cursorType)
 
virtual MouseCursor getMouseCursor ()
 
void updateMouseCursor () const
 
virtual void paintOverChildren (Graphics &g)
 
virtual void mouseMove (const MouseEvent &event) override
 
virtual void mouseDoubleClick (const MouseEvent &event) override
 
virtual void mouseWheelMove (const MouseEvent &event, const MouseWheelDetails &wheel) override
 
virtual void mouseMagnify (const MouseEvent &event, float scaleFactor)
 
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 focusOfChildComponentChanged (FocusChangeType cause)
 
bool isMouseOver (bool includeChildren=false) const
 
bool isMouseButtonDown () const
 
bool isMouseOverOrDragging () 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)
 
int runModalLoop ()
 
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
 
void exitModalState (int returnValue)
 
bool isCurrentlyModal () 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 ()
 
virtual MarkerListgetMarkers (bool xAxis)
 
void * getWindowHandle () const
 
PositionergetPositioner () const noexcept
 
void setPositioner (Positioner *newPositioner)
 
void setCachedComponentImage (CachedComponentImage *newCachedImage)
 
CachedComponentImagegetCachedComponentImage () const noexcept
 
 JUCE_DEPRECATED (Point< int > relativePositionToGlobal(Point< int >) const)
 
 JUCE_DEPRECATED (Point< int > globalPositionToRelative(Point< int >) const)
 
 JUCE_DEPRECATED (Point< int > relativePositionToOtherComponent(const Component *, Point< int >) const)
 
- Public Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()
 
- Public Member Functions inherited from juce::SettableTooltipClient
virtual ~SettableTooltipClient ()
 
virtual String getTooltip ()
 
- Public Member Functions inherited from juce::TooltipClient
virtual ~TooltipClient ()
 

Protected Member Functions

 Button (const String &buttonName)
 
virtual void clicked ()
 
virtual void clicked (const ModifierKeys &modifiers)
 
virtual void paintButton (Graphics &g, bool isMouseOverButton, bool isButtonDown)=0
 
virtual void buttonStateChanged ()
 
virtual void internalClickCallback (const ModifierKeys &)
 
void handleCommandMessage (int commandId) override
 
void mouseEnter (const MouseEvent &) override
 
void mouseExit (const MouseEvent &) override
 
void mouseDown (const MouseEvent &) override
 
void mouseDrag (const MouseEvent &) override
 
void mouseUp (const MouseEvent &) override
 
bool keyPressed (const KeyPress &) override
 
void paint (Graphics &) override
 
void parentHierarchyChanged () override
 
void visibilityChanged () override
 
void focusGained (FocusChangeType) override
 
void focusLost (FocusChangeType) override
 
void enablementChanged () override
 
- Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
 
- Protected Member Functions inherited from juce::SettableTooltipClient
 SettableTooltipClient ()
 

Friends

class CallbackHelper
 
struct ContainerDeletePolicy< CallbackHelper >
 

Additional Inherited Members

- Static Public Member Functions inherited from juce::Component
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
 

Detailed Description

A base class for buttons.

This contains all the logic for button behaviours such as enabling/disabling, responding to shortcut keystrokes, auto-repeating when held down, toggle-buttons and radio groups, etc.

See also
TextButton, DrawableButton, ToggleButton

Member Enumeration Documentation

Used by setState().

Enumerator
buttonNormal 
buttonOver 
buttonDown 

A combination of these flags are used by setConnectedEdges().

Enumerator
ConnectedOnLeft 
ConnectedOnRight 
ConnectedOnTop 
ConnectedOnBottom 

Constructor & Destructor Documentation

Button::Button ( const String buttonName)
explicitprotected

Creates a button.

Parameters
buttonNamethe text to put in the button (the component's name is also initially set to this string, but these can be changed later using the setName() and setButtonText() methods)
Button::~Button ( )
virtual

Destructor.

Member Function Documentation

void Button::addListener ( Listener newListener)

Registers a listener to receive events when this button's state changes. If the listener is already registered, this will not register it again.

See also
removeListener
void Button::addShortcut ( const KeyPress key)

Assigns a shortcut key to trigger the button.

The button registers itself with its top-level parent component for keypresses.

Note that a different way of linking buttons to keypresses is by using the setCommandToTrigger() method to invoke a command.

See also
clearShortcuts
void Button::buttonStateChanged ( )
protectedvirtual

Called when the button's up/down/over state changes.

Subclasses can override this if they need to do something special when the button goes up or down.

See also
isDown, isOver

Reimplemented in juce::DrawableButton, and juce::ToolbarButton.

void Button::clearShortcuts ( )

Removes all key shortcuts that had been set for this button.

See also
addShortcut
void Button::clicked ( )
protectedvirtual

This method is called when the button has been clicked.

Subclasses can override this to perform whatever they actions they need to do.

Alternatively, a ButtonListener can be added to the button, and these listeners will be called when the click occurs.

See also
triggerClick

Reimplemented in juce::HyperlinkButton, juce::KeyMappingEditorComponent::ChangeKeyButton, and juce::ScrollBar::ScrollbarButton.

void Button::clicked ( const ModifierKeys modifiers)
protectedvirtual

This method is called when the button has been clicked.

By default it just calls clicked(), but you might want to override it to handle things like clicking when a modifier key is pressed, etc.

See also
ModifierKeys

Reimplemented in juce::TabBarButton.

void Button::enablementChanged ( )
overrideprotectedvirtual

Callback to indicate that this component has been enabled or disabled.

This can be triggered by one of the component's parent components being enabled or disabled, as well as changes to the component itself.

The default implementation of this method does nothing; your class may wish to repaint itself or something when this happens.

See also
setEnabled, isEnabled

Reimplemented from juce::Component.

Reimplemented in juce::DrawableButton, and juce::ToolbarButton.

void Button::focusGained ( FocusChangeType  cause)
overrideprotectedvirtual

Called to indicate that this component has just acquired the keyboard focus.

See also
focusLost, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus

Reimplemented from juce::Component.

void Button::focusLost ( FocusChangeType  cause)
overrideprotectedvirtual

Called to indicate that this component has just lost the keyboard focus.

See also
focusGained, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus

Reimplemented from juce::Component.

const String& juce::Button::getButtonText ( ) const
inline

Returns the text displayed in the button.

See also
setButtonText
bool Button::getClickingTogglesState ( ) const
noexcept

Returns true if this button is set to be an automatic toggle-button. This returns the last value that was passed to setClickingTogglesState().

CommandID juce::Button::getCommandID ( ) const
inlinenoexcept

Returns the command ID that was set by setCommandToTrigger().

int juce::Button::getConnectedEdgeFlags ( ) const
inlinenoexcept

Returns the set of flags passed into setConnectedEdges().

uint32 Button::getMillisecondsSinceButtonDown ( ) const
noexcept

Returns the number of milliseconds since the last time the button went into the 'down' state.

int juce::Button::getRadioGroupId ( ) const
inlinenoexcept

Returns the ID of the group to which this button belongs. (See setRadioGroupId() for an explanation of this).

ButtonState juce::Button::getState ( ) const
inlinenoexcept

Returns the button's current over/down/up state.

bool juce::Button::getToggleState ( ) const
inlinenoexcept

Returns true if the button is 'on'.

By default buttons are 'off' and for simple buttons that you click to perform an action you won't change this. Toggle buttons, however will want to change their state when turned on or off.

See also
setToggleState
Value& juce::Button::getToggleStateValue ( )
inlinenoexcept

Returns the Value object that represents the botton's toggle state. You can use this Value object to connect the button's state to external values or setters, either by taking a copy of the Value, or by using Value::referTo() to make it point to your own Value object.

See also
getToggleState, Value
void Button::handleCommandMessage ( int  commandId)
overrideprotectedvirtual

Called to handle a command that was sent by postCommandMessage().

This is called by the message thread when a command message arrives, and the component can override this method to process it in any way it needs to.

See also
postCommandMessage

Reimplemented from juce::Component.

void Button::internalClickCallback ( const ModifierKeys modifiers)
protectedvirtual
bool juce::Button::isConnectedOnBottom ( ) const
inlinenoexcept

Indicates whether the button adjoins another one on its bottom edge.

See also
setConnectedEdges
bool juce::Button::isConnectedOnLeft ( ) const
inlinenoexcept

Indicates whether the button adjoins another one on its left edge.

See also
setConnectedEdges
bool juce::Button::isConnectedOnRight ( ) const
inlinenoexcept

Indicates whether the button adjoins another one on its right edge.

See also
setConnectedEdges
bool juce::Button::isConnectedOnTop ( ) const
inlinenoexcept

Indicates whether the button adjoins another one on its top edge.

See also
setConnectedEdges
bool Button::isDown ( ) const
noexcept

Returns true if the button is currently being held down.

See also
isOver
bool Button::isOver ( ) const
noexcept

Returns true if the mouse is currently over the button. This will be also be true if the button is being held down.

See also
isDown
bool Button::isRegisteredForShortcut ( const KeyPress key) const

Returns true if the given keypress is a shortcut for this button.

See also
addShortcut
juce::Button::JUCE_DEPRECATED ( void   setToggleStatebool, bool)
bool Button::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.

void Button::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::Component.

void Button::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::Component.

void Button::mouseEnter ( const MouseEvent event)
overrideprotectedvirtual

Called when the mouse first enters a component.

If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this.

When the mouse button is pressed and held down while being moved in or out of a component, no mouseEnter or mouseExit callbacks are made - only mouseDrag messages are sent to the component that the mouse was originally clicked on, 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
mouseExit, mouseDrag, mouseMove, contains

Reimplemented from juce::Component.

void Button::mouseExit ( const MouseEvent event)
overrideprotectedvirtual

Called when the mouse moves out of a component.

This will be called when the mouse moves off the edge of this component.

If the mouse button was pressed, and it was then dragged off the edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback.

Parameters
eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseEnter, mouseDrag, mouseMove, contains

Reimplemented from juce::Component.

void Button::mouseUp ( const MouseEvent event)
overrideprotectedvirtual

Called when a mouse button is released.

A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.

The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.

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

Reimplemented from juce::Component.

void Button::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.

virtual void juce::Button::paintButton ( Graphics g,
bool  isMouseOverButton,
bool  isButtonDown 
)
protectedpure virtual

Subclasses should override this to actually paint the button's contents.

It's better to use this than the paint method, because it gives you information about the over/down state of the button.

Parameters
gthe graphics context to use
isMouseOverButtontrue if the button is either in the 'over' or 'down' state
isButtonDowntrue if the button should be drawn in the 'down' position

Implemented in juce::LookAndFeel_V2::GlassWindowButton, juce::LookAndFeel_V3_DocumentWindowButton, juce::ToolbarItemComponent, juce::DrawableButton, juce::ImageButton, juce::TabBarButton, juce::HyperlinkButton, juce::TextButton, juce::ShapeButton, juce::ToggleButton, juce::ArrowButton, juce::KeyMappingEditorComponent::ChangeKeyButton, and juce::ScrollBar::ScrollbarButton.

void Button::parentHierarchyChanged ( )
overrideprotectedvirtual

Called to indicate that the component's parents have changed.

When a component is added or removed from its parent, this method will be called on all of its children (recursively - so all children of its children will also be called as well).

Subclasses can override this if they need to react to this in some way.

See also
getParentComponent, isShowing, ComponentListener::componentParentHierarchyChanged

Reimplemented from juce::Component.

void Button::removeListener ( Listener listener)

Removes a previously-registered button listener

See also
addListener
void Button::setButtonText ( const String newText)

Changes the button's text.

See also
getButtonText
void Button::setClickingTogglesState ( bool  shouldAutoToggleOnClick)
noexcept

This tells the button to automatically flip the toggle state when the button is clicked.

If set to true, then before the clicked() callback occurs, the toggle-state of the button is flipped.

void Button::setCommandToTrigger ( ApplicationCommandManager commandManagerToUse,
CommandID  commandID,
bool  generateTooltip 
)

Sets a command ID for this button to automatically invoke when it's clicked.

When the button is pressed, it will use the given manager to trigger the command ID.

Obviously be careful that the ApplicationCommandManager doesn't get deleted before this button is. To disable the command triggering, call this method and pass nullptr as the command manager.

If generateTooltip is true, then the button's tooltip will be automatically generated based on the name of this command and its current shortcut key.

See also
addShortcut, getCommandID
void Button::setConnectedEdges ( int  connectedEdgeFlags)

Hints about which edges of the button might be connected to adjoining buttons.

The value passed in is a bitwise combination of any of the values in the ConnectedEdgeFlags enum.

E.g. if you are placing two buttons adjacent to each other, you could use this to indicate which edges are touching, and the LookAndFeel might choose to drawn them without rounded corners on the edges that connect. It's only a hint, so the LookAndFeel can choose to ignore it if it's not relevent for this type of button.

void Button::setRadioGroupId ( int  newGroupId,
NotificationType  notification = sendNotification 
)

Enables the button to act as a member of a mutually-exclusive group of 'radio buttons'.

If the group ID is set to a non-zero number, then this button will act as part of a group of buttons with the same ID, only one of which can be 'on' at the same time. Note that when it's part of a group, clicking a toggle-button that's 'on' won't turn it off.

To find other buttons with the same ID, this button will search through its sibling components for ToggleButtons, so all the buttons for a particular group must be placed inside the same parent component.

Set the group ID back to zero if you want it to act as a normal toggle button again.

The notification argument lets you specify how other buttons should react to being turned on or off in response to this call.

See also
getRadioGroupId
void Button::setRepeatSpeed ( int  initialDelayInMillisecs,
int  repeatDelayInMillisecs,
int  minimumDelayInMillisecs = -1 
)
noexcept

Sets an auto-repeat speed for the button when it is held down.

(Auto-repeat is disabled by default).

Parameters
initialDelayInMillisecshow long to wait after the mouse is pressed before triggering the next click. If this is zero, auto-repeat is disabled
repeatDelayInMillisecsthe frequently subsequent repeated clicks should be triggered
minimumDelayInMillisecsif this is greater than 0, the auto-repeat speed will get faster, the longer the button is held down, up to the minimum interval specified here
void Button::setState ( ButtonState  newState)

Can be used to force the button into a particular state.

This only changes the button's appearance, it won't trigger a click, or stop any mouse-clicks from happening.

The state that you set here will only last until it is automatically changed when the mouse enters or exits the button, or the mouse-button is pressed or released.

void Button::setToggleState ( bool  shouldBeOn,
NotificationType  notification 
)

A button has an on/off state associated with it, and this changes that.

By default buttons are 'off' and for simple buttons that you click to perform an action you won't change this. Toggle buttons, however will want to change their state when turned on or off.

Parameters
shouldBeOnwhether to set the button's toggle state to be on or off. If it's a member of a button group, this will always try to turn it on, and to turn off any other buttons in the group
notificationdetermines the behaviour if the value changes - this can invoke a synchronous call to clicked(), but sendNotificationAsync is not supported
See also
getToggleState, setRadioGroupId
void Button::setTooltip ( const String newTooltip)
overridevirtual

Sets the tooltip for this button.

See also
TooltipClient, TooltipWindow

Reimplemented from juce::SettableTooltipClient.

void Button::setTriggeredOnMouseDown ( bool  isTriggeredOnMouseDown)
noexcept

Sets whether the button click should happen when the mouse is pressed or released.

By default the button is only considered to have been clicked when the mouse is released, but setting this to true will make it call the clicked() method as soon as the button is pressed.

This is useful if the button is being used to show a pop-up menu, as it allows the click to be used as a drag onto the menu.

void Button::triggerClick ( )
virtual

Causes the button to act as if it's been clicked.

This will asynchronously make the button draw itself going down and up, and will then call back the clicked() method as if mouse was clicked on it.

See also
clicked
void Button::visibilityChanged ( )
overrideprotectedvirtual

Called when this component's visibility changes.

See also
setVisible, isVisible

Reimplemented from juce::Component.

Friends And Related Function Documentation

friend class CallbackHelper
friend
friend struct ContainerDeletePolicy< CallbackHelper >
friend

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