Skip to content

Commit b8a6d5a

Browse files
authored
Draggable type has a bool you can backdoor read to see if drag or type (#196)
1 parent 23a9944 commit b8a6d5a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

include/sst/jucegui/components/DraggableTextEditableValue.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,21 @@ struct DraggableTextEditableValue : public ContinuousParamEditor, public style::
7474

7575
void activateEditor();
7676

77+
bool isSetFromDrag() const { return isEditDrag; }
78+
7779
protected:
7880
float valueOnMouseDown{0.f};
7981
float displayUnits{false};
8082
bool everDragged{false};
8183
std::unique_ptr<juce::TextEditor> underlyingEditor;
84+
85+
bool isEditDrag{false};
86+
struct EditIsDragGuard
87+
{
88+
DraggableTextEditableValue &w;
89+
EditIsDragGuard(DraggableTextEditableValue &w) : w(w) { w.isEditDrag = true; }
90+
~EditIsDragGuard() { w.isEditDrag = false; }
91+
};
8292
};
8393
} // namespace sst::jucegui::components
8494

src/sst/jucegui/components/DraggableTextEditableValue.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ void DraggableTextEditableValue::mouseDrag(const juce::MouseEvent &e)
123123
auto fac = 0.5f * (e.mods.isShiftDown() ? 0.1f : 1.f);
124124
auto nv = valueOnMouseDown - fac * d * continuous()->getMinMaxRange() * 0.01f;
125125
nv = std::clamp(nv, continuous()->getMin(), continuous()->getMax());
126-
continuous()->setValueFromGUI(nv);
126+
{
127+
auto eidg = EditIsDragGuard(*this);
128+
continuous()->setValueFromGUI(nv);
129+
}
127130
repaint();
128131
}
129132

0 commit comments

Comments
 (0)