Skip to content

Commit

Permalink
Improvements on context aware spinbox behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
BatchDrake committed Jun 6, 2024
1 parent c7e724a commit f81ea9e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ContextAwareSpinBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ int BlockCursorStyle::pixelMetric(
void
ContextAwareSpinBox::focusInEvent(QFocusEvent *event)
{
int prefixLen = static_cast<int>(prefix().size());
int suffixLen = static_cast<int>(suffix().size());
int textLen = static_cast<int>(lineEdit()->text().length());
int dec = decimals();
int decSize = dec > 0 ? dec + 1 : 0;
int intLen = textLen - decSize - (prefixLen + suffixLen);

lineEdit()->setCursorPosition(prefixLen + intLen);

QDoubleSpinBox::focusInEvent(event);
}

Expand Down

0 comments on commit f81ea9e

Please sign in to comment.