Draft: fix number_length for imperial dimensions (#25369)

* The number_length function did not take imperial dimensions into account. For `9" + 7/8"` it would return 1.
* In ArchRoof reference number_length function from DraftGui.py to avoid duplicate code.
This commit is contained in:
Roy-043
2025-11-24 05:30:09 +01:00
committed by GitHub
parent be2b432ac4
commit 3344bc804c
2 changed files with 7 additions and 14 deletions

View File

@@ -1108,13 +1108,5 @@ if FreeCAD.GuiUp:
def eventFilter(self, widget, event):
if event.type() == QtCore.QEvent.FocusIn:
widget.setSelection(0, self.number_length(widget.text()))
widget.setSelection(0, FreeCADGui.draftToolBar.number_length(widget.text()))
return super().eventFilter(widget, event)
def number_length(self, str):
# Code taken from DraftGui.py.
nl = 0
for char in str:
if char in "0123456789.,-":
nl += 1
return nl

View File

@@ -803,11 +803,12 @@ class DraftToolBar:
self.xValue.setFocus()
self.xValue.setSelection(0, self.number_length(self.xValue.text()))
def number_length(self, str):
nl = 0
for char in str:
if char in "0123456789.,-":
nl += 1
def number_length(self, st):
nl = len(st)
for char in st[::-1]:
if char in "0123456789.,-+/":
break
nl -= 1
return nl
def extraLineUi(self):