JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Button.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
31 public Value::Listener,
32 public KeyListener
33{
34 CallbackHelper (Button& b) : button (b) {}
35
36 void timerCallback() override
37 {
38 button.repeatTimerCallback();
39 }
40
41 bool keyStateChanged (bool, Component*) override
42 {
43 return button.keyStateChangedCallback();
44 }
45
46 void valueChanged (Value& value) override
47 {
48 if (value.refersToSameSourceAs (button.isOn))
50 }
51
52 bool keyPressed (const KeyPress&, Component*) override
53 {
54 // returning true will avoid forwarding events for keys that we're using as shortcuts
55 return button.isShortcutPressed();
56 }
57
59 {
60 if (info.commandID == button.commandID
62 button.flashButtonState();
63 }
64
66 {
67 button.applicationCommandListChangeCallback();
68 }
69
70 Button& button;
71
73};
74
75//==============================================================================
76Button::Button (const String& name) : Component (name), text (name)
77{
78 callbackHelper.reset (new CallbackHelper (*this));
79
81 isOn.addListener (callbackHelper.get());
82}
83
85{
87
88 if (commandManagerToUse != nullptr)
89 commandManagerToUse->removeListener (callbackHelper.get());
90
91 isOn.removeListener (callbackHelper.get());
92 callbackHelper.reset();
93}
94
95//==============================================================================
97{
98 if (text != newText)
99 {
100 text = newText;
101 repaint();
102 }
103}
104
106{
108 generateTooltip = false;
109}
110
111void Button::updateAutomaticTooltip (const ApplicationCommandInfo& info)
112{
113 if (generateTooltip && commandManagerToUse != nullptr)
114 {
115 auto tt = info.description.isNotEmpty() ? info.description
116 : info.shortName;
117
118 for (auto& kp : commandManagerToUse->getKeyMappings()->getKeyPressesAssignedToCommand (commandID))
119 {
120 auto key = kp.getTextDescription();
121
122 tt << " [";
123
124 if (key.length() == 1)
125 tt << TRANS ("shortcut") << ": '" << key << "']";
126 else
127 tt << key << ']';
128 }
129
131 }
132}
133
135{
136 if (connectedEdgeFlags != newFlags)
137 {
138 connectedEdgeFlags = newFlags;
139 repaint();
140 }
141}
142
143//==============================================================================
144void Button::checkToggleableState (bool wasToggleable)
145{
148}
149
151{
152 const auto wasToggleable = isToggleable();
153
154 canBeToggled = isNowToggleable;
155 checkToggleableState (wasToggleable);
156}
157
162
164{
165 if (shouldBeOn != lastToggleState)
166 {
168
169 if (shouldBeOn)
170 {
171 turnOffOtherButtonsInGroup (clickNotification, stateNotification);
172
173 if (deletionWatcher == nullptr)
174 return;
175 }
176
177 // This test is done so that if the value is void rather than explicitly set to
178 // false, the value won't be changed unless the required value is true.
179 if (getToggleState() != shouldBeOn)
180 {
181 isOn = shouldBeOn;
182
183 if (deletionWatcher == nullptr)
184 return;
185 }
186
187 lastToggleState = shouldBeOn;
188 repaint();
189
191 {
192 // async callbacks aren't possible here
194
195 sendClickMessage (ModifierKeys::currentModifiers);
196
197 if (deletionWatcher == nullptr)
198 return;
199 }
200
202 sendStateMessage();
203 else
205
206 if (auto* handler = getAccessibilityHandler())
207 handler->notifyAccessibilityEvent (AccessibilityEvent::valueChanged);
208 }
209}
210
211void Button::setToggleState (bool shouldBeOn, bool sendChange)
212{
214}
215
217{
218 const auto wasToggleable = isToggleable();
219
220 clickTogglesState = shouldToggle;
221 checkToggleableState (wasToggleable);
222
223 // if you've got clickTogglesState turned on, you shouldn't also connect the button
224 // up to be a command invoker. Instead, your command handler must flip the state of whatever
225 // it is that this button represents, and the button will update its state to reflect this
226 // in the applicationCommandListChanged() method.
227 jassert (commandManagerToUse == nullptr || ! clickTogglesState);
228}
229
231{
232 if (radioGroupId != newGroupId)
233 {
234 radioGroupId = newGroupId;
235
236 if (lastToggleState)
237 turnOffOtherButtonsInGroup (notification, notification);
238
239 setToggleable (true);
241 }
242}
243
244void Button::turnOffOtherButtonsInGroup (NotificationType clickNotification, NotificationType stateNotification)
245{
246 if (auto* p = getParentComponent())
247 {
248 if (radioGroupId != 0)
249 {
251
252 for (auto* c : p->getChildren())
253 {
254 if (c != this)
255 {
256 if (auto b = dynamic_cast<Button*> (c))
257 {
258 if (b->getRadioGroupId() == radioGroupId)
259 {
260 b->setToggleState (false, clickNotification, stateNotification);
261
262 if (deletionWatcher == nullptr)
263 return;
264 }
265 }
266 }
267 }
268 }
269 }
270}
271
272//==============================================================================
274{
275 updateState();
276 repaint();
277}
278
279Button::ButtonState Button::updateState()
280{
281 return updateState (isMouseOver (true), isMouseButtonDown());
282}
283
284Button::ButtonState Button::updateState (bool over, bool down)
285{
286 ButtonState newState = buttonNormal;
287
289 {
290 if ((down && (over || (triggerOnMouseDown && buttonState == buttonDown))) || isKeyDown)
291 newState = buttonDown;
292 else if (over)
293 newState = buttonOver;
294 }
295
297 return newState;
298}
299
301{
302 if (buttonState != newState)
303 {
304 buttonState = newState;
305 repaint();
306
307 if (buttonState == buttonDown)
308 {
309 buttonPressTime = Time::getApproximateMillisecondCounter();
310 lastRepeatTime = 0;
311 }
312
313 sendStateMessage();
314 }
315}
316
317bool Button::isDown() const noexcept { return buttonState == buttonDown; }
318bool Button::isOver() const noexcept { return buttonState != buttonNormal; }
319
321
323{
325 return now > buttonPressTime ? now - buttonPressTime : 0;
326}
327
329{
330 triggerOnMouseDown = isTriggeredOnMouseDown;
331}
332
334{
335 return triggerOnMouseDown;
336}
337
338//==============================================================================
340{
341}
342
344{
345 clicked();
346}
347
348enum { clickMessageId = 0x2f3f4f99 };
349
351{
352 postCommandMessage (clickMessageId);
353}
354
355void Button::internalClickCallback (const ModifierKeys& modifiers)
356{
357 if (clickTogglesState)
358 {
359 const bool shouldBeOn = (radioGroupId != 0 || ! lastToggleState);
360
361 if (shouldBeOn != getToggleState())
362 {
364 return;
365 }
366 }
367
368 sendClickMessage (modifiers);
369}
370
371void Button::flashButtonState()
372{
373 if (isEnabled())
374 {
375 needsToRelease = true;
376 setState (buttonDown);
377 callbackHelper->startTimer (100);
378 }
379}
380
382{
383 if (commandId == clickMessageId)
384 {
385 if (isEnabled())
386 {
387 flashButtonState();
388 internalClickCallback (ModifierKeys::currentModifiers);
389 }
390 }
391 else
392 {
394 }
395}
396
397//==============================================================================
398void Button::addListener (Listener* l) { buttonListeners.add (l); }
399void Button::removeListener (Listener* l) { buttonListeners.remove (l); }
400
401void Button::sendClickMessage (const ModifierKeys& modifiers)
402{
404
405 if (commandManagerToUse != nullptr && commandID != 0)
406 {
409 info.originatingComponent = this;
410
411 commandManagerToUse->invoke (info, true);
412 }
413
415
416 if (checker.shouldBailOut())
417 return;
418
419 buttonListeners.callChecked (checker, [this] (Listener& l) { l.buttonClicked (this); });
420
421 if (checker.shouldBailOut())
422 return;
423
424 NullCheckedInvocation::invoke (onClick);
425}
426
427void Button::sendStateMessage()
428{
429 Component::BailOutChecker checker (this);
430
432
433 if (checker.shouldBailOut())
434 return;
435
436 buttonListeners.callChecked (checker, [this] (Listener& l) { l.buttonStateChanged (this); });
437
438 if (checker.shouldBailOut())
439 return;
440
441 NullCheckedInvocation::invoke (onStateChange);
442}
444//==============================================================================
446{
447 if (needsToRelease && isEnabled())
448 {
449 needsToRelease = false;
450 needsRepainting = true;
451 }
452
453 paintButton (g, isOver(), isDown());
454 lastStatePainted = buttonState;
455}
456
457//==============================================================================
458void Button::mouseEnter (const MouseEvent&) { updateState (true, false); }
459void Button::mouseExit (const MouseEvent&) { updateState (false, false); }
460
462{
463 updateState (true, true);
464
465 if (isDown())
466 {
467 if (autoRepeatDelay >= 0)
468 callbackHelper->startTimer (autoRepeatDelay);
469
470 if (triggerOnMouseDown)
471 internalClickCallback (e.mods);
472 }
473}
474
476{
477 const auto wasDown = isDown();
478 const auto wasOver = isOver();
479 updateState (isMouseSourceOver (e), false);
480
481 if (wasDown && wasOver && ! triggerOnMouseDown)
482 {
483 if (lastStatePainted != buttonDown)
484 flashButtonState();
485
487
488 internalClickCallback (e.mods);
489
490 if (deletionWatcher != nullptr)
491 updateState (isMouseSourceOver (e), false);
492 }
493}
494
496{
497 auto oldState = buttonState;
498 updateState (isMouseSourceOver (e), true);
499
500 if (autoRepeatDelay >= 0 && buttonState != oldState && isDown())
501 callbackHelper->startTimer (autoRepeatSpeed);
502}
503
504bool Button::isMouseSourceOver (const MouseEvent& e)
505{
506 if (e.source.isTouch() || e.source.isPen())
508
509 return isMouseOver();
510}
511
513{
514 updateState();
515 repaint();
516}
517
519{
520 updateState();
521 repaint();
522}
523
525{
526 needsToRelease = false;
527 updateState();
528}
529
531{
532 auto* newKeySource = shortcuts.isEmpty() ? nullptr : getTopLevelComponent();
533
534 if (newKeySource != keySource.get())
535 {
536 if (keySource != nullptr)
537 keySource->removeKeyListener (callbackHelper.get());
538
539 keySource = newKeySource;
540
541 if (keySource != nullptr)
542 keySource->addKeyListener (callbackHelper.get());
543 }
544}
545
546//==============================================================================
549{
550 commandID = newCommandID;
551 generateTooltip = generateTip;
552
553 if (commandManagerToUse != newCommandManager)
554 {
555 if (commandManagerToUse != nullptr)
556 commandManagerToUse->removeListener (callbackHelper.get());
557
558 commandManagerToUse = newCommandManager;
559
560 if (commandManagerToUse != nullptr)
561 commandManagerToUse->addListener (callbackHelper.get());
562
563 // if you've got clickTogglesState turned on, you shouldn't also connect the button
564 // up to be a command invoker. Instead, your command handler must flip the state of whatever
565 // it is that this button represents, and the button will update its state to reflect this
566 // in the applicationCommandListChanged() method.
567 jassert (commandManagerToUse == nullptr || ! clickTogglesState);
568 }
569
570 if (commandManagerToUse != nullptr)
571 applicationCommandListChangeCallback();
572 else
573 setEnabled (true);
574}
575
576void Button::applicationCommandListChangeCallback()
577{
578 if (commandManagerToUse != nullptr)
579 {
580 ApplicationCommandInfo info (0);
581
582 if (commandManagerToUse->getTargetForCommand (commandID, info) != nullptr)
583 {
584 updateAutomaticTooltip (info);
587 }
588 else
589 {
590 setEnabled (false);
591 }
592 }
593}
594
595//==============================================================================
597{
598 if (key.isValid())
599 {
600 jassert (! isRegisteredForShortcut (key)); // already registered!
601
602 shortcuts.add (key);
604 }
605}
606
608{
609 shortcuts.clear();
611}
612
613bool Button::isShortcutPressed() const
614{
616 for (auto& s : shortcuts)
617 if (s.isCurrentlyDown())
618 return true;
619
620 return false;
621}
622
624{
625 for (auto& s : shortcuts)
626 if (key == s)
627 return true;
628
629 return false;
630}
631
632bool Button::keyStateChangedCallback()
633{
634 if (! isEnabled())
635 return false;
636
637 const bool wasDown = isKeyDown;
638 isKeyDown = isShortcutPressed();
639
640 if (autoRepeatDelay >= 0 && (isKeyDown && ! wasDown))
641 callbackHelper->startTimer (autoRepeatDelay);
642
643 updateState();
644
645 if (isEnabled() && wasDown && ! isKeyDown)
646 {
647 internalClickCallback (ModifierKeys::currentModifiers);
648
649 // (return immediately - this button may now have been deleted)
650 return true;
651 }
652
653 return wasDown || isKeyDown;
654}
655
657{
659 {
660 triggerClick();
661 return true;
662 }
663
664 return false;
665}
666
667//==============================================================================
669 int repeatMillisecs,
670 int minimumDelayInMillisecs) noexcept
671{
672 autoRepeatDelay = initialDelayMillisecs;
673 autoRepeatSpeed = repeatMillisecs;
674 autoRepeatMinimumDelay = jmin (autoRepeatSpeed, minimumDelayInMillisecs);
675}
676
677void Button::repeatTimerCallback()
678{
679 if (needsRepainting)
680 {
681 callbackHelper->stopTimer();
682 updateState();
683 needsRepainting = false;
684 }
685 else if (autoRepeatSpeed > 0 && (isKeyDown || (updateState() == buttonDown)))
686 {
687 auto repeatSpeed = autoRepeatSpeed;
688
689 if (autoRepeatMinimumDelay >= 0)
690 {
691 auto timeHeldDown = jmin (1.0, getMillisecondsSinceButtonDown() / 4000.0);
693
694 repeatSpeed = repeatSpeed + (int) (timeHeldDown * (autoRepeatMinimumDelay - repeatSpeed));
695 }
696
698
699 auto now = Time::getMillisecondCounter();
700
701 // if we've been blocked from repeating often enough, speed up the repeat timer to compensate..
702 if (lastRepeatTime != 0 && (int) (now - lastRepeatTime) > repeatSpeed * 2)
703 repeatSpeed = jmax (1, repeatSpeed / 2);
704
705 lastRepeatTime = now;
706 callbackHelper->startTimer (repeatSpeed);
707
708 internalClickCallback (ModifierKeys::currentModifiers);
709 }
710 else if (! needsToRelease)
711 {
712 callbackHelper->stopTimer();
713 }
714}
715
717{
718 return std::make_unique<detail::ButtonAccessibilityHandler> (*this, AccessibilityRole::button);
719}
720
721} // namespace juce
A listener that receives callbacks from an ApplicationCommandManager when commands are invoked or the...
One of these objects holds a list of all the commands your app can perform, and despatches these comm...
void addListener(ApplicationCommandManagerListener *listener)
Registers a listener that will be called when various events occur.
ApplicationCommandTarget * getTargetForCommand(CommandID commandID, ApplicationCommandInfo &upToDateInfo)
Tries to find the best target to use to perform a given command.
bool invoke(const ApplicationCommandTarget::InvocationInfo &invocationInfo, bool asynchronously)
Sends a command to the default target.
void removeListener(ApplicationCommandManagerListener *listener)
Deregisters a previously-added listener.
Used to receive callbacks when a button is clicked.
A base class for buttons.
Definition juce_Button.h:43
void setState(ButtonState newState)
Can be used to force the button into a particular state.
void focusLost(FocusChangeType) override
Called to indicate that this component has just lost the keyboard focus.
void setConnectedEdges(int connectedEdgeFlags)
Hints about which edges of the button might be connected to adjoining buttons.
virtual void clicked()
This method is called when the button has been clicked.
virtual void buttonStateChanged()
Called when the button's up/down/over state changes.
bool isRegisteredForShortcut(const KeyPress &) const
Returns true if the given keypress is a shortcut for this button.
bool keyPressed(const KeyPress &) override
Called when a key is pressed.
bool getToggleState() const noexcept
Returns true if the button is 'on'.
void setToggleState(bool shouldBeOn, NotificationType notification)
A button has an on/off state associated with it, and this changes that.
void setButtonText(const String &newText)
Changes the button's text.
void handleCommandMessage(int commandId) override
Called to handle a command that was sent by postCommandMessage().
void setCommandToTrigger(ApplicationCommandManager *commandManagerToUse, CommandID commandID, bool generateTooltip)
Sets a command ID for this button to automatically invoke when it's clicked.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
Button(const String &buttonName)
Creates a button.
void setTriggeredOnMouseDown(bool isTriggeredOnMouseDown) noexcept
Sets whether the button click should happen when the mouse is pressed or released.
void setToggleable(bool shouldBeToggleable)
Indicates that the button's on/off state is toggleable.
void clearShortcuts()
Removes all key shortcuts that had been set for this button.
bool isToggleable() const noexcept
Returns true if the button's on/off state is toggleable.
uint32 getMillisecondsSinceButtonDown() const noexcept
Returns the number of milliseconds since the last time the button went into the 'down' state.
std::function< void()> onClick
You can assign a lambda to this callback object to have it called when the button is clicked.
bool isDown() const noexcept
Returns true if the button is currently being held down.
~Button() override
Destructor.
void removeListener(Listener *listener)
Removes a previously-registered button listener.
bool isOver() const noexcept
Returns true if the mouse is currently over the button.
void focusGained(FocusChangeType) override
Called to indicate that this component has just acquired the keyboard focus.
void setRepeatSpeed(int initialDelayInMillisecs, int repeatDelayInMillisecs, int minimumDelayInMillisecs=-1) noexcept
Sets an auto-repeat speed for the button when it is held down.
void addShortcut(const KeyPress &)
Assigns a shortcut key to trigger the button.
void paint(Graphics &) override
Components can override this method to draw their content.
void addListener(Listener *newListener)
Registers a listener to receive events when this button's state changes.
void visibilityChanged() override
Called when this component's visibility changes.
void mouseDrag(const MouseEvent &) override
Called when the mouse is moved while a button is held down.
void mouseDown(const MouseEvent &) override
Called when a mouse button is pressed.
void parentHierarchyChanged() override
Called to indicate that the component's parents have changed.
void mouseExit(const MouseEvent &) override
Called when the mouse moves out of a component.
virtual void paintButton(Graphics &g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown)=0
Subclasses should override this to actually paint the button's contents.
void mouseUp(const MouseEvent &) override
Called when a mouse button is released.
void setRadioGroupId(int newGroupId, NotificationType notification=sendNotification)
Enables the button to act as a member of a mutually-exclusive group of 'radio buttons'.
void mouseEnter(const MouseEvent &) override
Called when the mouse first enters a component.
bool getTriggeredOnMouseDown() const noexcept
Returns whether the button click happens when the mouse is pressed or released.
virtual void triggerClick()
Causes the button to act as if it's been clicked.
void setClickingTogglesState(bool shouldAutoToggleOnClick) noexcept
This tells the button to automatically flip the toggle state when the button is clicked.
std::function< void()> onStateChange
You can assign a lambda to this callback object to have it called when the button's state changes.
void setTooltip(const String &newTooltip) override
Sets the tooltip for this button.
ButtonState
Used by setState().
void enablementChanged() override
Callback to indicate that this component has been enabled or disabled.
A class to keep an eye on a component and check for it being deleted.
The base class for all JUCE user-interface objects.
bool isMouseButtonDown(bool includeChildren=false) const
Returns true if the mouse button is currently held down in this component.
Component * getTopLevelComponent() const noexcept
Returns the highest-level component which contains this one or its parents.
bool isVisible() const noexcept
Tests whether the component is visible or not.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
bool isShowing() const
Tests whether this component and all its parents are visible.
FocusChangeType
Enumeration used by the focusGained() and focusLost() methods.
bool isCurrentlyBlockedByAnotherModalComponent() const
Checks whether there's a modal component somewhere that's stopping this one from receiving messages.
AccessibilityHandler * getAccessibilityHandler()
Returns the accessibility handler for this component, or nullptr if this component is not accessible.
void postCommandMessage(int commandId)
Dispatches a numbered message to this component.
void setEnabled(bool shouldBeEnabled)
Enables or disables this component.
void repaint()
Marks the whole component as needing to be redrawn.
void setWantsKeyboardFocus(bool wantsFocus) noexcept
Sets a flag to indicate whether this component wants keyboard focus or not.
bool isMouseOver(bool includeChildren=false) const
Returns true if the mouse is currently over this component.
bool isEnabled() const noexcept
Returns true if the component (and all its parents) are enabled.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
const Array< Component * > & getChildren() const noexcept
Provides access to the underlying array of child components.
void invalidateAccessibilityHandler()
Invalidates the AccessibilityHandler that is currently being used for this component.
virtual void handleCommandMessage(int commandId)
Called to handle a command that was sent by postCommandMessage().
A graphics context, used for drawing a component or image.
Receives callbacks when keys are pressed.
Represents a key press, including any modifier keys that are needed.
bool isKeyCode(int keyCodeToCompare) const noexcept
Checks whether the KeyPress's key is the same as the one provided, without checking the modifiers.
bool isValid() const noexcept
Returns true if this is a valid KeyPress.
static const int returnKey
key-code for the return key
Represents the state of the mouse buttons and modifier keys.
static ModifierKeys currentModifiers
This object represents the last-known state of the keyboard and mouse buttons.
Contains position and status information about a mouse event.
const ModifierKeys mods
The key modifiers associated with the event.
MouseInputSource source
The source device that generated this event.
const Point< float > position
The position of the mouse when the event occurred.
bool isTouch() const noexcept
Returns true if this object represents a source of touch events.
bool isPen() const noexcept
Returns true if this object represents a pen device.
Rectangle< float > toFloat() const noexcept
Casts this rectangle to a Rectangle<float>.
bool contains(ValueType xCoord, ValueType yCoord) const noexcept
Returns true if this coordinate is inside the rectangle.
virtual void setTooltip(const String &newTooltip)
Assigns a new tooltip to this object.
The JUCE String class!
Definition juce_String.h:53
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
static uint32 getApproximateMillisecondCounter() noexcept
Less-accurate but faster version of getMillisecondCounter().
static uint32 getMillisecondCounter() noexcept
Returns the number of millisecs since a fixed event (usually system startup).
Makes repeated callbacks to a virtual method at a specified time interval.
Definition juce_Timer.h:52
Receives callbacks when a Value object changes.
Definition juce_Value.h:139
Represents a shared variant value.
Definition juce_Value.h:51
void addListener(Listener *listener)
Adds a listener to receive callbacks when the value changes.
void removeListener(Listener *listener)
Removes a listener that was previously added with addListener().
bool refersToSameSourceAs(const Value &other) const
Returns true if this object and the other one use the same underlying ValueSource object.
var getValue() const
Returns the current value.
This class acts as a pointer which will automatically become null if the object to which it points is...
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
#define jassert(expression)
Platform-independent assertion macro.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
typedef int
JUCE Namespace.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
@ valueChanged
Indicates that the UI element's value has changed.
NotificationType
These enums are used in various classes to indicate whether a notification event should be sent out.
@ sendNotificationAsync
Requests an asynchronous notification.
@ sendNotification
Requests a notification message, either synchronous or not.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
int CommandID
A type used to hold the unique ID for an application command.
Holds information describing an application command.
int flags
A bitwise-OR of the values specified in the CommandFlags enum.
String description
A longer description of the command.
@ isTicked
Indicates that the command should have a tick next to it on a menu.
@ dontTriggerVisualFeedback
If this flag is present and the command is invoked from a keypress, then any buttons or menus that ar...
@ isDisabled
Indicates that the command can't currently be performed.
String shortName
A short name to describe the command.
Contains contextual details about the invocation of a command.
@ fromButton
The command is being invoked by a button click.
CommandID commandID
The UID of the command that should be performed.
bool keyPressed(const KeyPress &, Component *) override
Called to indicate that a key has been pressed.
void valueChanged(Value &value) override
Called when a Value object is changed.
void applicationCommandListChanged() override
Called when commands are registered or deregistered from the command manager, or when commands are ma...
void applicationCommandInvoked(const ApplicationCommandTarget::InvocationInfo &info) override
Called when an app command is about to be invoked.
bool keyStateChanged(bool, Component *) override
Called when any key is pressed or released.
void timerCallback() override
The user-defined callback routine that actually gets called periodically.