@@ -366,7 +366,30 @@ class DraggableNumber : public Label
366366 nvgTextLetterSpacing (nvg, 0 .275f );
367367 nvgTextAlign (nvg, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT);
368368 nvgFillColor (nvg, NVGComponent::convertColour (textColour));
369- nvgText (nvg, textArea.getX (), textArea.getCentreY () + 1 .5f , numberText.toRawUTF8 (), nullptr );
369+
370+ // NOTE: We could simply do `String(numberText.getDoubleValue(), 0)` but using string manipulation
371+ // bypasses any potential issues with precision
372+ auto removeDecimalNumString = [](String& numString) {
373+ if (numString.contains (" ." )) {
374+ // Split the string into the integer and fractional parts
375+ StringArray parts = StringArray::fromTokens (numString, " ." , " " );
376+
377+ // If the fractional part is "0" or empty, remove the decimal point
378+ if (parts[1 ] == " 0" || parts[1 ].isEmpty ()) {
379+ return parts[0 ]; // Just keep the integer part
380+ } else {
381+ return numString; // Keep the full string (with decimal point & fractional part)
382+ }
383+ } else {
384+ // If there’s no decimal point, leave the string as it is
385+ return numString;
386+ }
387+ };
388+
389+ // Only display the decimal point if fractional exists, but make sure to show it as a user hovers over the fractional decimal places
390+ auto formatedNumber = isMouseOverOrDragging () && hoveredDecimal > 0 ? numberText : removeDecimalNumString (numberText);
391+
392+ nvgText (nvg, textArea.getX (), textArea.getCentreY () + 1 .5f , formatedNumber.toRawUTF8 (), nullptr );
370393
371394 if (dragMode == Regular) {
372395 textArea = textArea.withTrimmedLeft (numberTextLength);
0 commit comments