Repository: nvaccess/nvda

Issue:
Add an input gesture to change the mouse text unit resolution value
### Is your feature request related to a problem? Please describe.
In some cases, I use the mouse tracking feature of NVDA to read text that is under the mouse cursor. I've set the mouse "text unit resolution" value to "line" and for most cases until recently, it was OK. But now that NVDA's mouse tracking works more as it should in regards to text unit resolution in places such as Microsoft Edge, I've started thinking that in some cases reading by line is OK, but in some other cases, reading by paragraph is better. So, a way to switch quickly between the text unit resolution modes (character, word, line, paragraph) would be welcome. I've looked and there is no NVDA input gesture for that at the moment. The only way to change the mouse text unit resolution is to go into the NVDA's settings, in the "Mouse" category and change it from there.

### Describe the solution you'd like
So, I think that there should be a way to assign an NVDA input gesture to quickly change the value for the mouse text unit resolution.

### Describe alternatives you've considered
Changing the value for the mouse text unit resolution each time I want to change it via NVDA's settings panel takes too many steps. Changing it via configuration profiles also seams a bit too complicated, considering in most cases I want to change it quickly and temporarily for a specific case.


Discussion:

Resolving patch:
diff --git a/source/globalCommands.py b/source/globalCommands.py
--- a/source/globalCommands.py
+++ b/source/globalCommands.py
@@ -1428,6 +1428,25 @@ def script_toggleMouseTracking(self,gesture):
 	script_toggleMouseTracking.__doc__=_("Toggles the reporting of information as the mouse moves")
 	script_toggleMouseTracking.category=SCRCAT_MOUSE
 
+	def script_toggleMouseTextResolution(self,gesture):
+		values = textInfos.MOUSE_TEXT_RESOLUTION_UNITS
+		labels = [textInfos.unitLabels[x] for x in values]
+		try:
+			index = values.index(config.conf["mouse"]["mouseTextUnit"])
+		except ValueError:
+			log.debugWarning("Couldn't get current mouse text resolution setting", exc_info=True)
+			default = 				config.conf.getConfigValidation(("mouse", "mouseTextUnit")).default
+			index = values.index(default)
+		newIndex = (index+1) % len(values)
+		config.conf["mouse"]["mouseTextUnit"]= values[newIndex]
+		# Translators: Reports the new state of the mouse text unit resolution:.
+		# %s will be replaced with the new label.
+		# For example, the full message might be "Mouse text unit resolution character"
+		ui.message(_("Mouse text unit resolution %s")%labels[newIndex])
+	# Translators: Input help mode message for toggle mouse text unit resolution command.
+	script_toggleMouseTextResolution.__doc__=_("Toggles how much text will be spoken when the mouse moves")
+	script_toggleMouseTextResolution.category=SCRCAT_MOUSE
+
 	def script_title(self,gesture):
 		obj=api.getForegroundObject()
 		title=obj.name
diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py
--- a/source/gui/settingsDialogs.py
+++ b/source/gui/settingsDialogs.py
@@ -1389,7 +1389,7 @@ def makeSettings(self, settingsSizer):
 		# mouse settings panel.
 		textUnitLabelText=_("Text &unit resolution:")
 		import textInfos
-		self.textUnits=[textInfos.UNIT_CHARACTER,textInfos.UNIT_WORD,textInfos.UNIT_LINE,textInfos.UNIT_PARAGRAPH]
+		self.textUnits=textInfos.MOUSE_TEXT_RESOLUTION_UNITS
 		textUnitsChoices = [textInfos.unitLabels[x] for x in self.textUnits]
 		self.textUnitComboBox=sHelper.addLabeledControl(textUnitLabelText, wx.Choice, choices=textUnitsChoices)
 		try:
diff --git a/source/textInfos/__init__.py b/source/textInfos/__init__.py
--- a/source/textInfos/__init__.py
+++ b/source/textInfos/__init__.py
@@ -235,6 +235,8 @@ def __ne__(self,other):
 UNIT_READINGCHUNK="readingChunk"
 UNIT_OFFSET="offset"
 
+MOUSE_TEXT_RESOLUTION_UNITS = (UNIT_CHARACTER,UNIT_WORD,UNIT_LINE,UNIT_PARAGRAPH)
+
 unitLabels={
 	UNIT_CHARACTER:_("character"),
 	UNIT_WORD:_("word"),


Test patch: