Skip to content

Commit

Permalink
Merge pull request #1 from ibrahim-s/doubleGestureIssue
Browse files Browse the repository at this point in the history
double gesture issue
  • Loading branch information
cary-rowen committed Sep 1, 2023
2 parents 6fe1cd4 + 83e3ec8 commit 6312ca7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions addon/globalPlugins/objWatcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(self):
super().__init__()
self.watchingObj = None
self.lastAttributeText = None
# self.callLater will be assigned the value wx.CallLater(510, _toggleWatcher), used to stop calling the function when the gesture presse twice.
# Borrowed from Luke's Version collector addon. Thanks Luke
self.callLater= None
self.timer = wx.Timer(gui.mainFrame)
gui.mainFrame.Bind(
wx.EVT_TIMER, handler=self.onTimerEvent, source=self.timer)
Expand All @@ -43,14 +46,19 @@ def script_startOrStopWatcher(self, gesture):
return
repeatCount = getLastScriptRepeatCount()
if repeatCount > 0:
# stop the effects of first press.
if self.callLater.IsRunning():
self.callLater.Stop()
if not self.timer.IsRunning():
return
self._toggleWatcher()
else:
if self.timer.IsRunning():
ui.message(self._getWatchingAttribute())
else:
self._toggleWatcher()
self.callLater= wx.CallLater(510, self._toggleWatcher) if not self.callLater else self.callLater
# call after 510 ms, and we will stop it if gesture press twice.
self.callLater.Start(510)

def _toggleWatcher(self):
if self.timer.IsRunning():
Expand All @@ -60,8 +68,8 @@ def _toggleWatcher(self):
ui.message(_("Stopped watcher"))
else:
self.watchingObj = api.getNavigatorObject()
self.timer.Start(WATCHER_TIMER_INTERVAL)
if self.watchingObj:
self.timer.Start(WATCHER_TIMER_INTERVAL)
cues.Start()
# Translators: Messages reported when watcher is started.
ui.message(_("Started watcher {}").format(
Expand Down

0 comments on commit 6312ca7

Please sign in to comment.