Repository: silx-kit/silx
Issue: [GUI] Interactive zoom lost when de-activating the mask

To reproduce:

- Execute the silx `./examples/imageview.py`
- Activate the mask
- Select a mask drawing mode
- Close the mask

The widget enters panning mode and one cannot get out of it

Changed files:
src/silx/gui/plot/ScatterMaskToolsWidget.py, src/silx/gui/plot/_BaseMaskToolsWidget.py, src/silx/gui/plot/MaskToolsWidget.py

diff --git a/src/silx/gui/plot/MaskToolsWidget.py b/src/silx/gui/plot/MaskToolsWidget.py
index 46b532cbd..abead9dbc 100644
--- a/src/silx/gui/plot/MaskToolsWidget.py
+++ b/src/silx/gui/plot/MaskToolsWidget.py
@@ -1,6 +1,6 @@
 # /*##########################################################################
 #
-# Copyright (c) 2017-2021 European Synchrotron Radiation Facility
+# Copyright (c) 2017-2022 European Synchrotron Radiation Facility
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -416,7 +416,7 @@ class MaskToolsWidget(BaseMaskToolsWidget):
 
         if self.isMaskInteractionActivated():
             # Disable drawing tool
-            self.browseAction.trigger()
+            self.plot.resetInteractiveMode()
 
         if self.isItemMaskUpdated():  # No "after-care"
             self._data = numpy.zeros((0, 0), dtype=numpy.uint8)
diff --git a/src/silx/gui/plot/ScatterMaskToolsWidget.py b/src/silx/gui/plot/ScatterMaskToolsWidget.py
index 3f8c28b66..5c82fcf57 100644
--- a/src/silx/gui/plot/ScatterMaskToolsWidget.py
+++ b/src/silx/gui/plot/ScatterMaskToolsWidget.py
@@ -1,6 +1,6 @@
 # /*##########################################################################
 #
-# Copyright (c) 2018-2021 European Synchrotron Radiation Facility
+# Copyright (c) 2018-2022 European Synchrotron Radiation Facility
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -287,8 +287,10 @@ class ScatterMaskToolsWidget(BaseMaskToolsWidget):
             self.plot.sigActiveScatterChanged.disconnect(self._activeScatterChanged)
         except (RuntimeError, TypeError):
             _logger.info(sys.exc_info()[1])
-        if not self.browseAction.isChecked():
-            self.browseAction.trigger()  # Disable drawing tool
+
+        if self.isMaskInteractionActivated():
+            # Disable drawing tool
+            self.plot.resetInteractiveMode()
 
         if self.getSelectionMask(copy=False) is not None:
             self.plot.sigActiveScatterChanged.connect(
diff --git a/src/silx/gui/plot/_BaseMaskToolsWidget.py b/src/silx/gui/plot/_BaseMaskToolsWidget.py
index dda75e1b6..1673137ad 100644
--- a/src/silx/gui/plot/_BaseMaskToolsWidget.py
+++ b/src/silx/gui/plot/_BaseMaskToolsWidget.py
@@ -918,8 +918,8 @@ class BaseMaskToolsWidget(qt.QWidget):
         if (event.type() == qt.QEvent.EnabledChange and
                 not self.isEnabled() and
                 self.drawActionGroup.checkedAction()):
-            # Disable drawing tool by setting interaction to zoom
-            self.browseAction.trigger()
+            # Disable drawing tool by reseting interaction to pan or zoom
+            self.plot.resetInteractiveMode()
 
     def save(self, filename, kind):
         """Save current mask in a file