Repository: nvaccess/nvda

Issue:
Add alternative way to report name of the current Excel sheet which don't require moving review cursor into Excel window
### Is your feature request related to a problem? Please describe.
I am often working with Excel workbooks containing multiple sheets and at the same time reading some instructions or data in another program with review cursor to avoid moving back and forth between two windows. In this case there is no easy way for me to determine in which sheet I am, because NVDA+ numpad delete works only when review cursor is in the Excel window.
### Describe the solution you'd like
There should be a command (NVDA+Alt+s perhaps) to announce name of the current sheet. 
### Describe alternatives you've considered
NVDA+tab might eventually announce current sheet name or maybe NVDA+t.
### Additional context
For the sighted users the sheet name is visible regardless of how many windows they have open, in which window they mouse cursor is if the Excel window is visible. Furthermore we are interested in the sheet in which we have focus not in the sheet in which our review cursor is similar to NVDA+tab. I understand that in the default config they are in the same place, but if we aren't accounting for the users which are using it separately why even create options to make them separate.


Discussion:
Hi, NVDA+Numpad Delete (NvDA+Delete in laptop layout) should read current sheet name (or at least the sheet number) along with cell coordinates. Thanks.

 

From: Łukasz Golonka <notifications@github.com> 
Sent: Saturday, January 12, 2019 8:49 AM
To: nvaccess/nvda <nvda@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: [nvaccess/nvda] Add alternative way to report name of the current Excel sheet which don't require moving review cursor into Excel window (#9147)

 


Is your feature request related to a problem? Please describe.


I am often working with Excel workbooks containing multiple sheets and at the same time reading some instructions or data in another program with review cursor to avoid moving back and forth between two windows. In this case there is no easy way for me to determine in which sheet I am.


Describe the solution you'd like


There should be a command (NVDA+Alt+s perhaps) to announce name of the current sheet.


Describe alternatives you've considered


NVDA+tab might eventually announce current sheet name or maybe NVDA+t.


Additional context


For the sighted users the sheet name is visible regardless of how many windows they have open, in which window they mouse cursor is if the Excel window is visible. Furthermore we are interested in the sheet in which we have focus not in the sheet in which our review cursor it. I understand that in the default config they are in the same place, but if we aren't accounting for the users which are using it separately why even create options to make them separate.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <https://github.com/nvaccess/nvda/issues/9147> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgLkFzWGlDJ4NQSgDEXgV1zIbfWFGUaks5vChIVgaJpZM4Z8vVb> .


NVDA+numpad delete would read current sheet name only if the review cursor is placed in the Excel window, that why I have created this issue in the first place.
Hi, right. In the future, can you specify this kind of limitation (including the relevant command) so we can narrow this down a bit further? Thanks, and I hope those investigating it will know which direction they should not pursue.

 

From: Łukasz Golonka <notifications@github.com> 
Sent: Saturday, January 12, 2019 9:21 AM
To: nvaccess/nvda <nvda@noreply.github.com>
Cc: Joseph Lee <joseph.lee22590@gmail.com>; Comment <comment@noreply.github.com>
Subject: Re: [nvaccess/nvda] Add alternative way to report name of the current Excel sheet which don't require moving review cursor into Excel window (#9147)

 

NVDA+numpad delete would read current sheet name only if the review cursor is placed in the Excel window, that why I have created this issue in the first place.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <https://github.com/nvaccess/nvda/issues/9147#issuecomment-453764944> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgLkMz9RE9lyJ3oTxzsD_l4u7E4dNOIks5vChl7gaJpZM4Z8vVb> .


@josephsl Sorry about that. I've updated issue description accordingly.
I think it would make sense to have a script that reports the focus object along with its focus ancestors (i.e. the ancestors that are shown in braille as well.
@leonardder wrote:
> 
> 
> I think it would make sense to have a script that reports the focus object along with its focus ancestors (i.e. the ancestors that are shown in braille as well.


Are there other cases in which such script might be useful in your opinion? If so, are you going to work on this?
C can't think of any other advantages, but pretty sure that it makes sense to have such a script.
We can do one of the following:
1. _implement a new script:
2. Extend the report focus script to report ancestry at the third activation.


Resolving patch:
diff --git a/source/globalCommands.py b/source/globalCommands.py
--- a/source/globalCommands.py
+++ b/source/globalCommands.py
@@ -7,7 +7,7 @@
 # Julien Cochuyt, Jakub Lukowicz
 
 import itertools
-from typing import Optional
+from typing import Optional, Tuple, Union
 
 import audioDucking
 import touchHandler
@@ -1066,6 +1066,62 @@ def script_navigatorObject_current(self,gesture):
 		else:
 			speech.speakObject(curObject, reason=controlTypes.OutputReason.QUERY)
 
+	@staticmethod
+	def _reportLocationText(objs: Tuple[Union[None, NVDAObject, textInfos.TextInfo], ...]) -> None:
+		for obj in objs:
+			if obj is not None and obj.locationText:
+				ui.message(obj.locationText)
+				return
+		# Translators: message when there is no location information
+		ui.message(_("No location information"))
+
+	@script(
+		description=_(
+			# Translators: Description for a keyboard command which reports location of the
+			# review cursor, falling back to the location of navigator object if needed.
+			"Reports information about the location of the text at the review cursor "
+			"or location of the navigator object if there is no text under review cursor."
+		),
+		category=SCRCAT_OBJECTNAVIGATION,
+	)
+	def script_reportReviewCursorLocation(self, gesture):
+		self._reportLocationText((api.getReviewPosition(), api.getNavigatorObject()))
+
+	@script(
+		description=_(
+			# Translators: Description for a keyboard command which reports location of the navigator object.
+			"Reports information about the location of the current navigator object."
+		),
+		category=SCRCAT_OBJECTNAVIGATION,
+	)
+	def script_reportCurrentNavigatorObjectLocation(self, gesture):
+		self._reportLocationText((api.getNavigatorObject(),))
+
+	@script(
+		description=_(
+			# Translators: Description for a keyboard command which reports location of the
+			# current caret position falling back to the location of focused object if needed.
+			"Reports information about the location of the text at the caret, "
+			"or location of the currently focused object if there is no caret."
+		),
+		category=SCRCAT_SYSTEMCARET,
+	)
+	def script_reportCaretLocation(self, gesture):
+		self._reportLocationText(
+			(self._getTIAtCaret(fallbackToPOSITION_FIRST=True, reportFailure=False), api.getFocusObject())
+		)
+
+	@script(
+		description=_(
+			# Translators: Description for a keyboard command which reports location of the
+			# currently focused object.
+			"Reports information about the location of the currently focused object"
+		),
+		category=SCRCAT_FOCUS,
+	)
+	def script_reportFocusObjectLocation(self, gesture):
+		self._reportLocationText((api.getFocusObject(),))
+
 	@script(
 		description=_(
 			# Translators: Description for report review cursor location command.
@@ -1073,18 +1129,30 @@ def script_navigatorObject_current(self,gesture):
 			"Pressing twice may provide further detail."
 		),
 		category=SCRCAT_OBJECTNAVIGATION,
+		gestures=("kb:NVDA+shift+numpadDelete", "kb(laptop):NVDA+shift+delete")
+	)
+	def script_navigatorObject_currentDimensions(self, gesture):
+		if scriptHandler.getLastScriptRepeatCount() == 0:
+			self.script_reportReviewCursorLocation(gesture)
+		else:
+			self.script_reportCurrentNavigatorObjectLocation(gesture)
+
+	@script(
+		description=_(
+			# Translators: Description for a keyboard command
+			# which reports location of the text at the caret position
+			# or object with focus if there is no caret.
+			"Reports information about the location of the text or object at the position of system caret "
+			"Pressing twice may provide further detail."
+		),
+		category=SCRCAT_SYSTEMCARET,
 		gestures=("kb:NVDA+numpadDelete", "kb(laptop):NVDA+delete")
 	)
-	def script_navigatorObject_currentDimensions(self,gesture):
-		count=scriptHandler.getLastScriptRepeatCount()
-		locationText=api.getReviewPosition().locationText if count==0 else None
-		if not locationText:
-			locationText=api.getNavigatorObject().locationText
-		if not locationText:
-			# Translators: message when there is no location information for the review cursor
-			ui.message(_("No location information"))
-			return
-		ui.message(locationText)
+	def script_caretPos_currentDimensions(self, gesture):
+		if scriptHandler.getLastScriptRepeatCount() == 0:
+			self.script_reportCaretLocation(gesture)
+		else:
+			self.script_reportFocusObjectLocation(gesture)
 
 	@script(
 		description=_(
@@ -1800,9 +1868,13 @@ def _reportFormattingHelper(self, info, browseable=False):
 			)
 
 	@staticmethod
-	def _getTIAtCaret(fallbackToPOSITION_FIRST=False):
+	def _getTIAtCaret(
+			fallbackToPOSITION_FIRST: bool = False,
+			reportFailure: bool = True
+	) -> Optional[textInfos.TextInfo]:
 		# Returns text info at the caret position if there is a caret in the current control, None otherwise.
-		# Note that if there is  no caret this fact is announced  in speech and braille.
+		# Note that if there is no caret this fact is announced in speech and braille
+		# unless reportFailure is set to C{False}
 		obj = api.getFocusObject()
 		treeInterceptor = obj.treeInterceptor
 		if(
@@ -1816,8 +1888,9 @@ def _getTIAtCaret(fallbackToPOSITION_FIRST=False):
 			if fallbackToPOSITION_FIRST:
 				return obj.makeTextInfo(textInfos.POSITION_FIRST)
 			else:
-				# Translators: Reported when there is no caret.
-				ui.message(_("No caret"))
+				if reportFailure:
+					# Translators: Reported when there is no caret.
+					ui.message(_("No caret"))
 
 	@script(
 		# Translators: Input help mode message for report formatting command.


Test patch: