Draft: fix handling of MouseDelay

The MouseDelay sets a point value to None. In some cases this point was then still used resulting in attribute errors.

See:
https://github.com/FreeCAD/FreeCAD/issues/19531#issuecomment-2651341711
This commit is contained in:
Roy-043
2025-07-15 20:29:44 +02:00
committed by Yorik van Havre
parent 6e68d94c78
commit a8a44aab0a
12 changed files with 30 additions and 0 deletions

View File

@@ -143,6 +143,8 @@ class Arc(gui_base_original.Creator):
if arg["Type"] == "SoKeyboardEvent":
if arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg)
# this is to make sure radius is what you see on screen

View File

@@ -93,6 +93,8 @@ class BezCurve(gui_lines.Line):
if arg["Key"] == "ESCAPE":
self.finish()
return
if not self.ui.mouse:
return
if arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg, noTracker=True)
# existing points + this pointer position
@@ -283,6 +285,8 @@ class CubicBezCurve(gui_lines.Line):
if arg["Key"] == "ESCAPE":
self.finish()
return
if not self.ui.mouse:
return
if arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg, noTracker=True)
if (len(self.node) - 1) % self.degree == 0 and len(self.node) > 2:

View File

@@ -163,6 +163,8 @@ class Ellipse(gui_base_original.Creator):
if arg["Type"] == "SoKeyboardEvent":
if arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg, noTracker=True)
self.rect.update(self.point)

View File

@@ -133,6 +133,8 @@ class Mirror(gui_base_original.Modifier):
if arg["Type"] == "SoKeyboardEvent":
if arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg)
if len(self.node) > 0:

View File

@@ -161,6 +161,8 @@ class Offset(gui_base_original.Modifier):
if arg["Type"] == "SoKeyboardEvent":
if arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event":
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg)
if (gui_tool_utils.hasMod(arg, gui_tool_utils.get_mod_constrain_key())

View File

@@ -79,6 +79,8 @@ class Point(gui_base_original.Creator):
It should automatically update the coordinates in the widgets
of the task panel.
"""
if not self.ui.mouse:
return
event = event_cb.getEvent()
mousepos = event.getPosition().getValue()
ctrl = event.wasCtrlDown()
@@ -101,6 +103,8 @@ class Point(gui_base_original.Creator):
It should act as if the Enter key was pressed, or the OK button
was pressed in the task panel.
"""
if not self.ui.mouse:
return
if event_cb:
event = event_cb.getEvent()
if (event.getState() != coin.SoMouseButtonEvent.DOWN or

View File

@@ -113,6 +113,8 @@ class Polygon(gui_base_original.Creator):
if arg["Type"] == "SoKeyboardEvent":
if arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg)
self.polygonTrack.update(ctrlPoint)

View File

@@ -158,6 +158,8 @@ class Rectangle(gui_base_original.Creator):
if arg["Type"] == "SoKeyboardEvent":
if arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg, noTracker=True)
self.rect.update(self.point)

View File

@@ -102,6 +102,8 @@ class Rotate(gui_base_original.Modifier):
"""
if arg["Type"] == "SoKeyboardEvent" and arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event":
self.handle_mouse_move_event(arg)
elif (arg["Type"] == "SoMouseButtonEvent"

View File

@@ -1395,6 +1395,8 @@ class Snapper:
self.callbackMove = None
def move(event_cb):
if not self.ui.mouse:
return
event = event_cb.getEvent()
mousepos = event.getPosition()
ctrl = event.wasCtrlDown()
@@ -1421,6 +1423,8 @@ class Snapper:
accept()
def click(event_cb):
if not self.ui.mouse:
return
event = event_cb.getEvent()
if event.getButton() == 1:
if event.getState() == coin.SoMouseButtonEvent.DOWN:

View File

@@ -85,6 +85,8 @@ class BSpline(gui_lines.Line):
if arg["Key"] == "ESCAPE":
self.finish()
return
if not self.ui.mouse:
return
if arg["Type"] == "SoLocation2Event": # mouse movement detection
self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg, noTracker=True)
self.bsplinetrack.update(self.node + [self.point])

View File

@@ -201,6 +201,8 @@ class Trimex(gui_base_original.Modifier):
if arg["Type"] == "SoKeyboardEvent":
if arg["Key"] == "ESCAPE":
self.finish()
elif not self.ui.mouse:
pass
elif arg["Type"] == "SoLocation2Event": # mouse movement detection
self.shift = gui_tool_utils.hasMod(arg, gui_tool_utils.get_mod_constrain_key())
self.alt = gui_tool_utils.hasMod(arg, gui_tool_utils.get_mod_alt_key())