From 7e89f5ef4d9be3cb8b9a7516350b2bbad6088ad9 Mon Sep 17 00:00:00 2001 From: hwf1324 <1398969445@qq.com> Date: Sun, 23 Mar 2025 18:25:30 +0800 Subject: [PATCH 1/3] Add EditableListBox control --- addon/globalPlugins/objWatcher/settings.py | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/addon/globalPlugins/objWatcher/settings.py b/addon/globalPlugins/objWatcher/settings.py index 161de98..cab9bc0 100644 --- a/addon/globalPlugins/objWatcher/settings.py +++ b/addon/globalPlugins/objWatcher/settings.py @@ -9,6 +9,10 @@ from gui import guiHelper from gui import nvdaControls +import wx +import wx.adv + + addonHandler.initTranslation() @@ -28,5 +32,27 @@ def makeSettings(self, settingsSizer): initial=int(config.conf["objWatcher"]["interval"]) ) + self._appendWatchAttributesList(settingsSizerHelper) + + def _appendWatchAttributesList(self, settingsSizerHelper: guiHelper.BoxSizerHelper) -> None: + self.watchAttributesList: wx.adv.EditableListBox = wx.adv.EditableListBox( + self, + label=_("Watch attributes"), + ) + self.watchAttributesList.SetStrings(config.conf["objWatcher"]["watchAttributes"].split(",")) + editBtn: wx.BitmapButton = self.watchAttributesList.GetEditButton() + editBtn.SetLabel(editBtn.GetToolTipText()) + newBtn: wx.BitmapButton = self.watchAttributesList.GetNewButton() + newBtn.SetLabel(newBtn.GetToolTipText()) + delBtn: wx.BitmapButton = self.watchAttributesList.GetDelButton() + delBtn.SetLabel(delBtn.GetToolTipText()) + upBtn: wx.BitmapButton = self.watchAttributesList.GetUpButton() + upBtn.SetLabel(upBtn.GetToolTipText()) + downBtn: wx.BitmapButton = self.watchAttributesList.GetDownButton() + downBtn.SetLabel(downBtn.GetToolTipText()) + + settingsSizerHelper.addItem(self.watchAttributesList) + def onSave(self): config.conf["objWatcher"]["interval"] = self.intervalEdit.Value + config.conf["objWatcher"]["watchAttributes"] = ",".join(self.watchAttributesList.GetStrings()) From 759f74d5b39700745c408ce2705790091e6ac268 Mon Sep 17 00:00:00 2001 From: hwf1324 <1398969445@qq.com> Date: Sun, 13 Apr 2025 01:52:49 +0800 Subject: [PATCH 2/3] Move the Tab order of the `ListBox` control before the Edit button. --- addon/globalPlugins/objWatcher/settings.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/addon/globalPlugins/objWatcher/settings.py b/addon/globalPlugins/objWatcher/settings.py index cab9bc0..d80bec2 100644 --- a/addon/globalPlugins/objWatcher/settings.py +++ b/addon/globalPlugins/objWatcher/settings.py @@ -20,7 +20,7 @@ class ObjWatcherPanel(gui.settingsDialogs.SettingsPanel): # Translators: This is the label for the ObjWatcher settings panel. title = _("ObjWatcher") - def makeSettings(self, settingsSizer): + def makeSettings(self, settingsSizer: wx.BoxSizer): settingsSizerHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) # Translators: This is the label of a SpinCtrl in the ObjWatcher settings panel # This option controls the interval of the Watcher timer (in milliseconds) @@ -35,11 +35,15 @@ def makeSettings(self, settingsSizer): self._appendWatchAttributesList(settingsSizerHelper) def _appendWatchAttributesList(self, settingsSizerHelper: guiHelper.BoxSizerHelper) -> None: + # Translators: This is the label of a EditableListBox in the ObjWatcher settings panel + # This list custom the attributes of the object to be watched + watchAttributesLabelText = _("Watch attributes") self.watchAttributesList: wx.adv.EditableListBox = wx.adv.EditableListBox( self, - label=_("Watch attributes"), + label=watchAttributesLabelText, ) self.watchAttributesList.SetStrings(config.conf["objWatcher"]["watchAttributes"].split(",")) + self.watchAttributesList.SetLabel(watchAttributesLabelText) editBtn: wx.BitmapButton = self.watchAttributesList.GetEditButton() editBtn.SetLabel(editBtn.GetToolTipText()) newBtn: wx.BitmapButton = self.watchAttributesList.GetNewButton() @@ -51,6 +55,12 @@ def _appendWatchAttributesList(self, settingsSizerHelper: guiHelper.BoxSizerHelp downBtn: wx.BitmapButton = self.watchAttributesList.GetDownButton() downBtn.SetLabel(downBtn.GetToolTipText()) + attrLst: wx.ListCtrl = self.watchAttributesList.GetListCtrl() + attrLst.MoveBeforeInTabOrder(editBtn.GetParent()) + attrLst.SetLabel(watchAttributesLabelText) + attrLst.EnableCheckBoxes(True) + attrLst.Select(0) + settingsSizerHelper.addItem(self.watchAttributesList) def onSave(self): From 0232e8aa86564bc099d7d337904819286b6572a4 Mon Sep 17 00:00:00 2001 From: hwf1324 <1398969445@qq.com> Date: Sun, 13 Apr 2025 19:49:40 +0800 Subject: [PATCH 3/3] Ignore the `wx.EVT_CHAR_HOOK` event of the settings dialog. --- addon/globalPlugins/objWatcher/settings.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addon/globalPlugins/objWatcher/settings.py b/addon/globalPlugins/objWatcher/settings.py index d80bec2..8bfa7a2 100644 --- a/addon/globalPlugins/objWatcher/settings.py +++ b/addon/globalPlugins/objWatcher/settings.py @@ -57,12 +57,24 @@ def _appendWatchAttributesList(self, settingsSizerHelper: guiHelper.BoxSizerHelp attrLst: wx.ListCtrl = self.watchAttributesList.GetListCtrl() attrLst.MoveBeforeInTabOrder(editBtn.GetParent()) + attrLst.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.onBeginEditingForListCtrl) attrLst.SetLabel(watchAttributesLabelText) attrLst.EnableCheckBoxes(True) attrLst.Select(0) settingsSizerHelper.addItem(self.watchAttributesList) + def onIgnoreDialogCharHookEvent(self, evt: wx.KeyEvent): + evt.DoAllowNextEvent() + + def onBeginEditingForListCtrl(self, evt: wx.ListEvent): + evtObj: wx.ListCtrl = evt.GetEventObject() + editCtrl = evtObj.GetEditControl() + if isinstance(editCtrl, wx.TextCtrl): + editCtrl.Bind(wx.EVT_CHAR_HOOK, handler=self.onIgnoreDialogCharHookEvent) + else: + evt.Skip() + def onSave(self): config.conf["objWatcher"]["interval"] = self.intervalEdit.Value config.conf["objWatcher"]["watchAttributes"] = ",".join(self.watchAttributesList.GetStrings())