From 2b853b0126656c07da50cb0cc42d83c86fc5a9c1 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Wed, 24 May 2023 20:35:24 +0200 Subject: [PATCH] Draft: Draft_CubicBezCurve: set EnableSelection to False, fixes #6452 (#9640) While the command is active set EnableSelection to False to correctly detect mouse up events. --- src/Mod/Draft/draftguitools/gui_beziers.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftguitools/gui_beziers.py b/src/Mod/Draft/draftguitools/gui_beziers.py index c84185128e..2cef26cdb3 100644 --- a/src/Mod/Draft/draftguitools/gui_beziers.py +++ b/src/Mod/Draft/draftguitools/gui_beziers.py @@ -37,6 +37,7 @@ See https://en.wikipedia.org/wiki/B%C3%A9zier_curve # @{ from PySide.QtCore import QT_TRANSLATE_NOOP +import FreeCAD as App import FreeCADGui as Gui import draftutils.utils as utils import draftutils.todo as todo @@ -228,11 +229,19 @@ Gui.addCommand('Draft_BezCurve', BezCurve()) class CubicBezCurve(gui_lines.Line): - """Gui command for the 3rd degree Bézier Curve tool.""" + """Gui command for the 3rd degree Bézier Curve tool. + + The EnableSelection parameter has an impact on SoMouseButtonEvents. If the + mouse is over a highlighted object and EnableSelection is `True` the mouse + up event is not detected. When this command is activated EnableSelection is + therefore temporarily set to `False`. + See: https://github.com/FreeCAD/FreeCAD/issues/6452 + """ def __init__(self): super(CubicBezCurve, self).__init__(wiremode=True) self.degree = 3 + self.old_EnableSelection = True def GetResources(self): """Set icon, menu and tooltip.""" @@ -247,6 +256,10 @@ class CubicBezCurve(gui_lines.Line): Activate the specific BezCurve tracker. """ + param = App.ParamGet("User parameter:BaseApp/Preferences/View") + self.old_EnableSelection = param.GetBool("EnableSelection", True) + param.SetBool("EnableSelection", False) + super(CubicBezCurve, self).Activated(name="CubicBezCurve", icon="Draft_CubicBezCurve") if self.doc: @@ -417,6 +430,9 @@ class CubicBezCurve(gui_lines.Line): closed: bool, optional Close the curve if `True`. """ + param = App.ParamGet("User parameter:BaseApp/Preferences/View") + param.SetBool("EnableSelection", self.old_EnableSelection) + if self.ui: if hasattr(self, "bezcurvetrack"): self.bezcurvetrack.finalize()