From 7b3e86ffc04a821466cebe0043d5f50de004d99f Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Fri, 5 Oct 2012 06:13:24 +1000 Subject: [PATCH] Elements list in browse mode: remember the last selected element type over each use of the dialog within a single running session of NVDA. Fixes #365 --- source/virtualBuffers/__init__.py | 12 +++++++++--- user_docs/en/changes.t2t | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/virtualBuffers/__init__.py b/source/virtualBuffers/__init__.py index 93c3aa88d..c1d3aef0b 100644 --- a/source/virtualBuffers/__init__.py +++ b/source/virtualBuffers/__init__.py @@ -271,6 +271,8 @@ class ElementsListDialog(wx.Dialog): ) Element = collections.namedtuple("Element", ("textInfo", "text", "parent")) + lastSelectedElementType=0 + def __init__(self, vbuf): self.vbuf = vbuf # Translators: The title of the browse mode Elements List dialog. @@ -280,6 +282,7 @@ class ElementsListDialog(wx.Dialog): # Translators: The label of a group of radio buttons to select the type of element # in the browse mode Elements List dialog. child = wx.RadioBox(self, wx.ID_ANY, label=_("Type:"), choices=tuple(et[1] for et in self.ELEMENT_TYPES)) + child.SetSelection(self.lastSelectedElementType) child.Bind(wx.EVT_RADIOBOX, self.onElementTypeChange) mainSizer.Add(child,proportion=1) @@ -317,12 +320,14 @@ class ElementsListDialog(wx.Dialog): self.SetSizer(mainSizer) self.tree.SetFocus() - self.initElementType(self.ELEMENT_TYPES[0][0]) + self.initElementType(self.ELEMENT_TYPES[self.lastSelectedElementType][0]) def onElementTypeChange(self, evt): + elementType=evt.GetInt() # We need to make sure this gets executed after the focus event. # Otherwise, NVDA doesn't seem to get the event. - queueHandler.queueFunction(queueHandler.eventQueue, self.initElementType, self.ELEMENT_TYPES[evt.GetInt()][0]) + queueHandler.queueFunction(queueHandler.eventQueue, self.initElementType, self.ELEMENT_TYPES[elementType][0]) + self.lastSelectedElementType=elementType def initElementType(self, elType): if elType == "link": @@ -532,7 +537,8 @@ class ElementsListDialog(wx.Dialog): def onAction(self, activate): self.Close() - + # Save off the last selected element type on to the class so its used in initialization next time. + self.__class__.lastSelectedElementType=self.lastSelectedElementType item = self.tree.GetSelection() element = self.tree.GetItemPyData(item).textInfo newCaret = element.copy() diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 37ee93f38..ed746336b 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -48,6 +48,7 @@ Highlights of this release include support for Asian character input; experiment - Object navigation commands (except the report current object command) now report with less verbosity. You can still obtain the extra information by using the report current object command. (#2560) - Updated liblouis braille translator to 2.5.1. (#2319, #2480, #2662, #2672) - The NVDA Key Commands Quick Reference document has been renamed to Commands Quick Reference, as it now includes touch commands as well as keyboard commands. +- The Elements list in Browse mode will now remember the last element type shown (e.g. links, headings or landmarks) each time the dialog is shown within the same session of NVDA. (#365) == Bug Fixes == -- 2.11.0