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

#include <juce_Label.h>

Inheritance diagram for juce::Label:
juce::Component juce::SettableTooltipClient juce::TextEditor::Listener juce::ComponentListener juce::Value::Listener juce::MouseListener juce::TooltipClient juce::LookAndFeel_V2::SliderLabelComp juce::TextPropertyComponent::LabelComp

Classes

class  Listener
struct  LookAndFeelMethods

Public Types

enum  ColourIds {
  backgroundColourId = 0x1000280 , textColourId = 0x1000281 , outlineColourId = 0x1000282 , backgroundWhenEditingColourId = 0x1000283 ,
  textWhenEditingColourId = 0x1000284 , outlineWhenEditingColourId = 0x1000285
}
Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }

Public Member Functions

 Label (const String &componentName=String(), const String &labelText=String())
 ~Label () override
void setText (const String &newText, NotificationType notification)
String getText (bool returnActiveEditorContents=false) const
ValuegetTextValue () noexcept
void setFont (const Font &newFont)
Font getFont () const noexcept
void setJustificationType (Justification justification)
Justification getJustificationType () const noexcept
void setBorderSize (BorderSize< int > newBorderSize)
BorderSize< intgetBorderSize () const noexcept
void attachToComponent (Component *owner, bool onLeft)
ComponentgetAttachedComponent () const
bool isAttachedOnLeft () const noexcept
void setMinimumHorizontalScale (float newScale)
float getMinimumHorizontalScale () const noexcept
void setKeyboardType (TextInputTarget::VirtualKeyboardType type) noexcept
void addListener (Listener *listener)
void removeListener (Listener *listener)
void setEditable (bool editOnSingleClick, bool editOnDoubleClick=false, bool lossOfFocusDiscardsChanges=false)
bool isEditableOnSingleClick () const noexcept
bool isEditableOnDoubleClick () const noexcept
bool doesLossOfFocusDiscardChanges () const noexcept
bool isEditable () const noexcept
void showEditor ()
void hideEditor (bool discardCurrentEditorContents)
bool isBeingEdited () const noexcept
TextEditorgetCurrentTextEditor () const noexcept
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
virtual void visibilityChanged ()
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 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 parentHierarchyChanged ()
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)
virtual void lookAndFeelChanged ()
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 ()
void setHasFocusOutline (bool hasFocusOutline) noexcept
bool hasFocusOutline () const noexcept
bool isEnabled () const noexcept
void setEnabled (bool shouldBeEnabled)
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 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 keyPressed (const KeyPress &key)
virtual bool keyStateChanged (bool isKeyDown)
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
virtual void focusLost (FocusChangeType cause)
virtual void focusOfChildComponentChanged (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 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)
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
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
Public Member Functions inherited from juce::SettableTooltipClient
 ~SettableTooltipClient () override=default
virtual void setTooltip (const String &newTooltip)
String getTooltip () override
Public Member Functions inherited from juce::TooltipClient
virtual ~TooltipClient ()=default

Public Attributes

std::function< void()> onTextChange
std::function< void()> onEditorShow
std::function< void()> onEditorHide

Protected Member Functions

virtual TextEditorcreateEditorComponent ()
virtual void textWasEdited ()
virtual void textWasChanged ()
virtual void editorShown (TextEditor *)
virtual void editorAboutToBeHidden (TextEditor *)
void paint (Graphics &) override
void resized () override
void mouseUp (const MouseEvent &) override
void mouseDoubleClick (const MouseEvent &) override
void componentMovedOrResized (Component &, bool wasMoved, bool wasResized) override
void componentParentHierarchyChanged (Component &) override
void componentVisibilityChanged (Component &) override
void inputAttemptWhenModal () override
void focusGained (FocusChangeType) override
void enablementChanged () override
std::unique_ptr< ComponentTraversercreateKeyboardFocusTraverser () override
void textEditorTextChanged (TextEditor &) override
void textEditorReturnKeyPressed (TextEditor &) override
void textEditorEscapeKeyPressed (TextEditor &) override
void textEditorFocusLost (TextEditor &) override
void colourChanged () override
void valueChanged (Value &) override
void callChangeListeners ()
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
Protected Member Functions inherited from juce::SettableTooltipClient
 SettableTooltipClient ()=default
Protected Member Functions inherited from juce::TextEditor::Listener
virtual ~Listener ()=default

Private Member Functions

std::unique_ptr< AccessibilityHandlercreateAccessibilityHandler () override
bool updateFromTextEditorContents (TextEditor &)
Private Member Functions inherited from juce::ComponentListener
virtual ~ComponentListener ()=default
virtual void componentBroughtToFront (Component &component)
virtual void componentChildrenChanged (Component &component)
virtual void componentNameChanged (Component &component)
virtual void componentBeingDeleted (Component &component)
virtual void componentEnablementChanged (Component &component)
Private Member Functions inherited from juce::Value::Listener
 Listener ()=default
virtual ~Listener ()=default

Private Attributes

Value textValue
String lastTextValue
Font font { 15.0f }
Justification justification = Justification::centredLeft
std::unique_ptr< TextEditoreditor
ListenerList< Listenerlisteners
WeakReference< ComponentownerComponent
BorderSize< intborder { 1, 5, 1, 5 }
float minimumHorizontalScale = 0
TextInputTarget::VirtualKeyboardType keyboardType = TextInputTarget::textKeyboard
bool editSingleClick = false
bool editDoubleClick = false
bool lossOfFocusDiscardsChanges = false
bool leftOfOwnerComp = false

Additional Inherited Members

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 Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)

Detailed Description

A component that displays a text string, and can optionally become a text editor when clicked.

@tags{GUI}

Member Enumeration Documentation

◆ ColourIds

enum juce::Label::ColourIds

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

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

Note that you can also use the constants from TextEditor::ColourIds to change the colour of the text editor that is opened when a label is editable.

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

The background colour to fill the label with.

textColourId 

The colour for the text.

outlineColourId 

An optional colour to use to draw a border around the label. Leave this transparent to not have an outline.

backgroundWhenEditingColourId 

The background colour when the label is being edited.

textWhenEditingColourId 

The colour for the text when the label is being edited.

outlineWhenEditingColourId 

An optional border colour when the label is being edited.

Constructor & Destructor Documentation

◆ Label()

juce::Label::Label ( const String & componentName = String(),
const String & labelText = String() )

Creates a Label.

Parameters
componentNamethe name to give the component
labelTextthe text to show in the label

◆ ~Label()

juce::Label::~Label ( )
override

Destructor.

Member Function Documentation

◆ addListener()

void juce::Label::addListener ( Label::Listener * l)

Registers a listener that will be called when the label's text changes.

◆ attachToComponent()

void juce::Label::attachToComponent ( Component * owner,
bool onLeft )

Makes this label "stick to" another component.

This will cause the label to follow another component around, staying either to its left or above it.

Parameters
ownerthe component to follow
onLeftif true, the label will stay on the left of its component; if false, it will stay above it.

◆ callChangeListeners()

void juce::Label::callChangeListeners ( )
protected

◆ colourChanged()

void juce::Label::colourChanged ( )
overrideprotectedvirtual

This method is called when a colour is changed by the setColour() method.

See also
setColour, findColour

Reimplemented from juce::Component.

◆ componentMovedOrResized()

void juce::Label::componentMovedOrResized ( Component & component,
bool wasMoved,
bool wasResized )
overrideprotectedvirtual

Called when the component's position or size changes.

Parameters
componentthe component that was moved or resized
wasMovedtrue if the component's top-left corner has just moved
wasResizedtrue if the component's width or height has just changed
See also
Component::setBounds, Component::resized, Component::moved

Reimplemented from juce::ComponentListener.

◆ componentParentHierarchyChanged()

void juce::Label::componentParentHierarchyChanged ( Component & component)
overrideprotectedvirtual

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

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

Parameters
componentthe component that this listener is registered with
See also
Component::parentHierarchyChanged

Reimplemented from juce::ComponentListener.

◆ componentVisibilityChanged()

void juce::Label::componentVisibilityChanged ( Component & component)
overrideprotectedvirtual

Called when the component is made visible or invisible.

Parameters
componentthe component that changed
See also
Component::setVisible

Reimplemented from juce::ComponentListener.

◆ createAccessibilityHandler()

std::unique_ptr< AccessibilityHandler > juce::Label::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.

Reimplemented in juce::LookAndFeel_V2::SliderLabelComp.

◆ createEditorComponent()

TextEditor * juce::Label::createEditorComponent ( )
protectedvirtual

Creates the TextEditor component that will be used when the user has clicked on the label. Subclasses can override this if they need to customise this component in some way.

Reimplemented in juce::TextPropertyComponent::LabelComp.

◆ createKeyboardFocusTraverser()

std::unique_ptr< ComponentTraverser > juce::Label::createKeyboardFocusTraverser ( )
overrideprotectedvirtual

Creates a ComponentTraverser object to use to determine the logic by which keyboard focus should be passed from this component.

The default implementation of this method will return an instance of KeyboardFocusTraverser if this component is a keyboard focus container (as determined by the setFocusContainerType() method). If the component isn't a keyboard focus container, then it will recursively call createKeyboardFocusTraverser() on its parents.

If you override this to return a custom traverser object, then this component and all its sub-components will use the new object to make their keyboard focusing decisions.

Reimplemented from juce::Component.

◆ doesLossOfFocusDiscardChanges()

bool juce::Label::doesLossOfFocusDiscardChanges ( ) const
inlinenoexcept

Returns true if this option has been set in a call to setEditable().

◆ editorAboutToBeHidden()

void juce::Label::editorAboutToBeHidden ( TextEditor * textEditor)
protectedvirtual

Called when the text editor is going to be deleted, after editing has finished.

◆ editorShown()

void juce::Label::editorShown ( TextEditor * textEditor)
protectedvirtual

Called when the text editor has just appeared, due to a user click or other focus change.

◆ enablementChanged()

void juce::Label::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.

◆ focusGained()

void juce::Label::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.

◆ getAttachedComponent()

Component * juce::Label::getAttachedComponent ( ) const

If this label has been attached to another component using attachToComponent, this returns the other component.

Returns nullptr if the label is not attached.

◆ getBorderSize()

BorderSize< int > juce::Label::getBorderSize ( ) const
inlinenoexcept

Returns the size of the border to be left around the text.

◆ getCurrentTextEditor()

TextEditor * juce::Label::getCurrentTextEditor ( ) const
noexcept

Returns the currently-visible text editor, or nullptr if none is open.

◆ getFont()

Font juce::Label::getFont ( ) const
noexcept

Returns the font currently being used. This may be the one set by setFont(), unless it has been overridden by the current LookAndFeel

See also
setFont

◆ getJustificationType()

Justification juce::Label::getJustificationType ( ) const
inlinenoexcept

Returns the type of justification, as set in setJustificationType().

◆ getMinimumHorizontalScale()

float juce::Label::getMinimumHorizontalScale ( ) const
inlinenoexcept

Specifies the amount that the font can be squashed horizontally.

◆ getText()

String juce::Label::getText ( bool returnActiveEditorContents = false) const

Returns the label's current text.

Parameters
returnActiveEditorContentsif this is true and the label is currently being edited, then this method will return the text as it's being shown in the editor. If false, then the value returned here won't be updated until the user has finished typing and pressed the return key.

◆ getTextValue()

Value & juce::Label::getTextValue ( )
inlinenoexcept

Returns the text content as a Value object. You can call Value::referTo() on this object to make the label read and control a Value object that you supply.

◆ hideEditor()

void juce::Label::hideEditor ( bool discardCurrentEditorContents)

Hides the editor if it was being shown.

Parameters
discardCurrentEditorContentsif true, the label's text will be reset to whatever it was before the editor was shown; if false, the current contents of the editor will be used to set the label's text before it is hidden.

◆ inputAttemptWhenModal()

void juce::Label::inputAttemptWhenModal ( )
overrideprotectedvirtual

Called when the user tries to click on a component that is blocked by another modal component.

When a component is modal and the user clicks on one of the other components, the modal component will receive this callback.

The default implementation of this method will play a beep, and bring the currently modal component to the front, but it can be overridden to do other tasks.

See also
isCurrentlyBlockedByAnotherModalComponent, canModalEventBeSentToComponent

Reimplemented from juce::Component.

◆ isAttachedOnLeft()

bool juce::Label::isAttachedOnLeft ( ) const
inlinenoexcept

If the label is attached to the left of another component, this returns true.

Returns false if the label is above the other component. This is only relevant if attachToComponent() has been called.

◆ isBeingEdited()

bool juce::Label::isBeingEdited ( ) const
noexcept

Returns true if the editor is currently focused and active.

◆ isEditable()

bool juce::Label::isEditable ( ) const
inlinenoexcept

Returns true if the user can edit this label's text.

◆ isEditableOnDoubleClick()

bool juce::Label::isEditableOnDoubleClick ( ) const
inlinenoexcept

Returns true if this option was set using setEditable().

◆ isEditableOnSingleClick()

bool juce::Label::isEditableOnSingleClick ( ) const
inlinenoexcept

Returns true if this option was set using setEditable().

◆ mouseDoubleClick()

void juce::Label::mouseDoubleClick ( const MouseEvent & event)
overrideprotectedvirtual

Called when a mouse button has been double-clicked on a component.

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.

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

Reimplemented from juce::Component.

◆ mouseUp()

void juce::Label::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.

◆ paint()

void juce::Label::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.

◆ removeListener()

void juce::Label::removeListener ( Label::Listener * l)

Deregisters a previously-registered listener.

◆ resized()

void juce::Label::resized ( )
overrideprotectedvirtual

Called when this component's size has been changed.

A component can implement this method to do things such as laying out its child components when its width or height changes.

The method is called synchronously as a result of the setBounds or setSize methods, so repeatedly changing a components size will repeatedly call its resized method (unlike things like repainting, where multiple calls to repaint are coalesced together).

If the component is a top-level window on the desktop, its size could also be changed by operating-system factors beyond the application's control.

See also
moved, setSize

Reimplemented from juce::Component.

◆ setBorderSize()

void juce::Label::setBorderSize ( BorderSize< int > newBorderSize)

Changes the border that is left between the edge of the component and the text. By default there's a small gap left at the sides of the component to allow for the drawing of the border, but you can change this if necessary.

◆ setEditable()

void juce::Label::setEditable ( bool editOnSingleClick,
bool editOnDoubleClick = false,
bool lossOfFocusDiscardsChanges = false )

Makes the label turn into a TextEditor when clicked.

By default this is turned off.

If turned on, then single- or double-clicking will turn the label into an editor. If the user then changes the text, then the ChangeBroadcaster base class will be used to send change messages to any listeners that have registered.

If the user changes the text, the textWasEdited() method will be called afterwards, and subclasses can override this if they need to do anything special.

Parameters
editOnSingleClickif true, just clicking once on the label will start editing the text
editOnDoubleClickif true, a double-click is needed to start editing
lossOfFocusDiscardsChangesif true, clicking somewhere else while the text is being edited will discard any changes; if false, then this will commit the changes.
See also
showEditor, setEditorColours, TextEditor

◆ setFont()

void juce::Label::setFont ( const Font & newFont)

Changes the font to use to draw the text.

See also
getFont

◆ setJustificationType()

void juce::Label::setJustificationType ( Justification justification)

Sets the style of justification to be used for positioning the text. (The default is Justification::centredLeft)

◆ setKeyboardType()

void juce::Label::setKeyboardType ( TextInputTarget::VirtualKeyboardType type)
inlinenoexcept

Set a keyboard type for use when the text editor is shown.

◆ setMinimumHorizontalScale()

void juce::Label::setMinimumHorizontalScale ( float newScale)

Specifies the minimum amount that the font can be squashed horizontally before it starts using ellipsis. Use a value of 0 for a default value.

See also
Graphics::drawFittedText

◆ setText()

void juce::Label::setText ( const String & newText,
NotificationType notification )

Changes the label text.

The NotificationType parameter indicates whether to send a change message to any Label::Listener objects if the new text is different.

◆ showEditor()

void juce::Label::showEditor ( )

Makes the editor appear as if the label had been clicked by the user.

See also
textWasEdited, setEditable

◆ textEditorEscapeKeyPressed()

void juce::Label::textEditorEscapeKeyPressed ( TextEditor & )
overrideprotectedvirtual

Called when the user presses the escape key.

Reimplemented from juce::TextEditor::Listener.

◆ textEditorFocusLost()

void juce::Label::textEditorFocusLost ( TextEditor & )
overrideprotectedvirtual

Called when the text editor loses focus.

Reimplemented from juce::TextEditor::Listener.

◆ textEditorReturnKeyPressed()

void juce::Label::textEditorReturnKeyPressed ( TextEditor & )
overrideprotectedvirtual

Called when the user presses the return key.

Reimplemented from juce::TextEditor::Listener.

◆ textEditorTextChanged()

void juce::Label::textEditorTextChanged ( TextEditor & )
overrideprotectedvirtual

Called when the user changes the text in some way.

Reimplemented from juce::TextEditor::Listener.

◆ textWasChanged()

void juce::Label::textWasChanged ( )
protectedvirtual

Called when the text has been altered.

◆ textWasEdited()

void juce::Label::textWasEdited ( )
protectedvirtual

Called after the user changes the text.

Reimplemented in juce::TextPropertyComponent::LabelComp.

◆ updateFromTextEditorContents()

bool juce::Label::updateFromTextEditorContents ( TextEditor & ed)
private

◆ valueChanged()

void juce::Label::valueChanged ( Value & value)
overrideprotectedvirtual

Called when a Value object is changed.

Note that the Value object passed as a parameter may not be exactly the same object that you registered the listener with - it might be a copy that refers to the same underlying ValueSource. To find out, you can call Value::refersToSameSourceAs().

Implements juce::Value::Listener.

Member Data Documentation

◆ border

BorderSize<int> juce::Label::border { 1, 5, 1, 5 }
private

◆ editDoubleClick

bool juce::Label::editDoubleClick = false
private

◆ editor

std::unique_ptr<TextEditor> juce::Label::editor
private

◆ editSingleClick

bool juce::Label::editSingleClick = false
private

◆ font

Font juce::Label::font { 15.0f }
private

◆ justification

Justification juce::Label::justification = Justification::centredLeft
private

◆ keyboardType

◆ lastTextValue

String juce::Label::lastTextValue
private

◆ leftOfOwnerComp

bool juce::Label::leftOfOwnerComp = false
private

◆ listeners

ListenerList<Listener> juce::Label::listeners
private

◆ lossOfFocusDiscardsChanges

bool juce::Label::lossOfFocusDiscardsChanges = false
private

◆ minimumHorizontalScale

float juce::Label::minimumHorizontalScale = 0
private

◆ onEditorHide

std::function<void()> juce::Label::onEditorHide

You can assign a lambda to this callback object to have it called when the label's editor is hidden.

◆ onEditorShow

std::function<void()> juce::Label::onEditorShow

You can assign a lambda to this callback object to have it called when the label's editor is shown.

◆ onTextChange

std::function<void()> juce::Label::onTextChange

You can assign a lambda to this callback object to have it called when the label text is changed.

◆ ownerComponent

WeakReference<Component> juce::Label::ownerComponent
private

◆ textValue

Value juce::Label::textValue
private

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