Skip to content

Commit ab48784

Browse files
committedFeb 14, 2025·
Fix more issues
1 parent 761c608 commit ab48784

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed
 

‎Source/Components/DraggableNumber.h

+18-15
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class DraggableNumber : public Component, public TextEditor::Listener
4848
std::unique_ptr<NanoVGGraphicsContext> nvgCtx;
4949

5050
public:
51-
std::function<void()> onTextChange;
52-
std::function<void()> onEditorShow;
53-
std::function<void()> onEditorHide;
51+
std::function<void()> onTextChange = [](){};
52+
std::function<void()> onEditorShow = [](){};
53+
std::function<void()> onEditorHide = [](){};
5454

5555
std::function<void(double)> onValueChange = [](double) { };
5656
std::function<void(double)> onReturnKey = [](double) { };
@@ -79,7 +79,7 @@ class DraggableNumber : public Component, public TextEditor::Listener
7979
textColour = findColour(Label::textColourId);
8080
}
8181

82-
void editorShown(Label* l, TextEditor& editor)
82+
void editorShown(TextEditor& editor)
8383
{
8484
onInteraction(true);
8585
dragStart();
@@ -222,21 +222,24 @@ class DraggableNumber : public Component, public TextEditor::Listener
222222
copyColourIfSpecified (*this, *editor, Label::outlineWhenEditingColourId, TextEditor::focusedOutlineColourId);
223223

224224
editor->setSize (10, 10);
225+
editor->setBorder(border);
226+
editor->setFont(font);
225227
addAndMakeVisible (editor.get());
226228
editor->setText (currentValue, false);
227-
//editor->setKeyboardType (keyboardType);
228229
editor->addListener (this);
229230
editor->grabKeyboardFocus();
230231

231232
if (editor == nullptr) // may be deleted by a callback
232233
return;
233234

235+
editor->setColour(TextEditor::backgroundColourId, Colours::transparentBlack);
234236
editor->setHighlightedRegion (Range<int> (0, currentValue.length()));
235237

236238
resized();
237239
repaint();
238240

239-
//editorShown (editor.get());
241+
editorShown(*editor);
242+
onEditorShow();
240243

241244
enterModalState (false);
242245
editor->grabKeyboardFocus();
@@ -271,18 +274,17 @@ class DraggableNumber : public Component, public TextEditor::Listener
271274
std::unique_ptr<TextEditor> outgoingEditor;
272275
std::swap (outgoingEditor, editor);
273276

274-
const bool changed = (! discardCurrentEditorContents)
275-
&& updateFromTextEditorContents (*outgoingEditor);
277+
if(!discardCurrentEditorContents) {
278+
updateFromTextEditorContents (*outgoingEditor);
279+
}
280+
276281
outgoingEditor.reset();
277282

278-
if (deletionChecker != nullptr)
283+
if (deletionChecker != nullptr) {
279284
repaint();
280-
281-
//if (changed)
282-
// textWasEdited();
283-
284-
if (deletionChecker != nullptr)
285-
exitModalState (0);
285+
onEditorHide();
286+
exitModalState(0);
287+
}
286288
}
287289
}
288290

@@ -767,6 +769,7 @@ class DraggableNumber : public Component, public TextEditor::Listener
767769
double const newValue = parseExpression(text);
768770
setValue(newValue, dontSendNotification);
769771
onReturnKey(newValue);
772+
hideEditor(false);
770773
}
771774
};
772775

0 commit comments

Comments
 (0)
Please sign in to comment.