@@ -48,9 +48,9 @@ class DraggableNumber : public Component, public TextEditor::Listener
48
48
std::unique_ptr<NanoVGGraphicsContext> nvgCtx;
49
49
50
50
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 = [](){} ;
54
54
55
55
std::function<void (double )> onValueChange = [](double ) { };
56
56
std::function<void (double )> onReturnKey = [](double ) { };
@@ -79,7 +79,7 @@ class DraggableNumber : public Component, public TextEditor::Listener
79
79
textColour = findColour (Label::textColourId);
80
80
}
81
81
82
- void editorShown (Label* l, TextEditor& editor)
82
+ void editorShown (TextEditor& editor)
83
83
{
84
84
onInteraction (true );
85
85
dragStart ();
@@ -222,21 +222,24 @@ class DraggableNumber : public Component, public TextEditor::Listener
222
222
copyColourIfSpecified (*this , *editor, Label::outlineWhenEditingColourId, TextEditor::focusedOutlineColourId);
223
223
224
224
editor->setSize (10 , 10 );
225
+ editor->setBorder (border);
226
+ editor->setFont (font);
225
227
addAndMakeVisible (editor.get ());
226
228
editor->setText (currentValue, false );
227
- // editor->setKeyboardType (keyboardType);
228
229
editor->addListener (this );
229
230
editor->grabKeyboardFocus ();
230
231
231
232
if (editor == nullptr ) // may be deleted by a callback
232
233
return ;
233
234
235
+ editor->setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
234
236
editor->setHighlightedRegion (Range<int > (0 , currentValue.length ()));
235
237
236
238
resized ();
237
239
repaint ();
238
240
239
- // editorShown (editor.get());
241
+ editorShown (*editor);
242
+ onEditorShow ();
240
243
241
244
enterModalState (false );
242
245
editor->grabKeyboardFocus ();
@@ -271,18 +274,17 @@ class DraggableNumber : public Component, public TextEditor::Listener
271
274
std::unique_ptr<TextEditor> outgoingEditor;
272
275
std::swap (outgoingEditor, editor);
273
276
274
- const bool changed = (! discardCurrentEditorContents)
275
- && updateFromTextEditorContents (*outgoingEditor);
277
+ if (!discardCurrentEditorContents) {
278
+ updateFromTextEditorContents (*outgoingEditor);
279
+ }
280
+
276
281
outgoingEditor.reset ();
277
282
278
- if (deletionChecker != nullptr )
283
+ if (deletionChecker != nullptr ) {
279
284
repaint ();
280
-
281
- // if (changed)
282
- // textWasEdited();
283
-
284
- if (deletionChecker != nullptr )
285
- exitModalState (0 );
285
+ onEditorHide ();
286
+ exitModalState (0 );
287
+ }
286
288
}
287
289
}
288
290
@@ -767,6 +769,7 @@ class DraggableNumber : public Component, public TextEditor::Listener
767
769
double const newValue = parseExpression (text);
768
770
setValue (newValue, dontSendNotification);
769
771
onReturnKey (newValue);
772
+ hideEditor (false );
770
773
}
771
774
};
772
775
0 commit comments