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.
This commit is contained in:
Roy-043
2023-05-24 20:35:24 +02:00
committed by GitHub
parent b801983109
commit 2b853b0126

View File

@@ -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()