Browse Source

Tweak to Button so that they will always visibly flash even if released before they had time to be painted in the down state

tags/2021-05-28
jules 9 years ago
parent
commit
4e48b3b661
2 changed files with 8 additions and 1 deletions
  1. +7
    -0
      modules/juce_gui_basics/buttons/juce_Button.cpp
  2. +1
    -1
      modules/juce_gui_basics/buttons/juce_Button.h

+ 7
- 0
modules/juce_gui_basics/buttons/juce_Button.cpp View File

@@ -84,6 +84,7 @@ Button::Button (const String& name)
connectedEdgeFlags (0),
commandID(),
buttonState (buttonNormal),
lastStatePainted (buttonNormal),
lastToggleState (false),
clickTogglesState (false),
needsToRelease (false),
@@ -430,6 +431,7 @@ void Button::paint (Graphics& g)
}
paintButton (g, isOver(), isDown());
lastStatePainted = buttonState;
}
//==============================================================================
@@ -457,7 +459,12 @@ void Button::mouseUp (const MouseEvent& e)
updateState (isMouseOver(), false);
if (wasDown && wasOver && ! triggerOnMouseDown)
{
if (lastStatePainted != buttonDown)
flashButtonState();
internalClickCallback (e.mods);
}
}
void Button::mouseDrag (const MouseEvent&)


+ 1
- 1
modules/juce_gui_basics/buttons/juce_Button.h View File

@@ -478,7 +478,7 @@ private:
int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay;
int radioGroupId, connectedEdgeFlags;
CommandID commandID;
ButtonState buttonState;
ButtonState buttonState, lastStatePainted;
Value isOn;
bool lastToggleState;


Loading…
Cancel
Save