Skip to content

Commit

Permalink
Add ability to disable the masking of passwords while typing
Browse files Browse the repository at this point in the history
  • Loading branch information
nvdaes committed Dec 3, 2024
1 parent 1fd469a commit 4a29866
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 6 deletions.
11 changes: 5 additions & 6 deletions source/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,15 @@ def setNavigatorObject(obj: NVDAObjects.NVDAObject, isFocus: bool = False) -> bo
return True


def isTypingProtected():
def isTypingProtected() -> bool:
"""Checks to see if key echo should be suppressed because the focus is currently on an object that has its protected state set.
@returns: True if it should be suppressed, False otherwise.
@rtype: boolean
:return: True if it should be suppressed, False otherwise.
"""
focusObject = getFocusObject()
if focusObject and focusObject.isProtected:
return True
else:
isFocusProtected = focusObject is not None and focusObject.isProtected
if not config.conf["keyboard"]["maskPasswords"]:
return False
return isFocusProtected


def createStateList(states):
Expand Down
1 change: 1 addition & 0 deletions source/config/configSpec.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
speechInterruptForEnter = boolean(default=true)
allowSkimReadingInSayAll = boolean(default=False)
alertForSpellingErrors = boolean(default=True)
maskPasswords = boolean(default=True)
handleInjectedKeys= boolean(default=true)
multiPressTimeout = integer(default=500, min=100, max=20000)
Expand Down
17 changes: 17 additions & 0 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,23 @@ def script_toggleSpeakCommandKeys(self, gesture):
config.conf["keyboard"]["speakCommandKeys"] = True
ui.message(state)

@script(
# Translators: Input help mode message for toggle masking passwords.
description=_("Toggles on and off the masking of passwords while typing"),
category=SCRCAT_SPEECH,
)
def script_toggleMaskingPasswords(self, gesture):
toggleBooleanValue(
configSection="keyboard",
configKey="maskPasswords",
# Translators: The message announced when toggling the mask passwords setting.
enabledMsg=_(
"Mask passwords while typing on",
),
# Translators: The message announced when toggling the mask passwords setting.
disabledMsg=_("mask passwords while typing off"),
)

@script(
# Translators: Input help mode message for toggle report font name command.
description=_("Toggles on and off the reporting of font changes"),
Expand Down
10 changes: 10 additions & 0 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,15 @@ def makeSettings(self, settingsSizer):
if not config.conf["documentFormatting"]["reportSpellingErrors"]:
self.alertForSpellingErrorsCheckBox.Disable()

# Translators: This is the label for a checkbox in the
# keyboard settings panel.
maskPasswordsText = _("Mask passwords while typing")
self.maskPasswordsCheckBox = sHelper.addItem(
wx.CheckBox(self, label=maskPasswordsText),
)
self.bindHelpEvent("MaskPasswordsWhileTyping", self.maskPasswordsCheckBox)
self.maskPasswordsCheckBox.SetValue(config.conf["keyboard"]["maskPasswords"])

# Translators: This is the label for a checkbox in the
# keyboard settings panel.
handleInjectedKeysText = _("Handle keys from other &applications")
Expand Down Expand Up @@ -2108,6 +2117,7 @@ def onSave(self):
config.conf["keyboard"]["beepForLowercaseWithCapslock"] = self.beepLowercaseCheckBox.IsChecked()
config.conf["keyboard"]["speakCommandKeys"] = self.commandKeysCheckBox.IsChecked()
config.conf["keyboard"]["alertForSpellingErrors"] = self.alertForSpellingErrorsCheckBox.IsChecked()
config.conf["keyboard"]["maskPasswords"] = self.maskPasswordsCheckBox.IsChecked()
config.conf["keyboard"]["handleInjectedKeys"] = self.handleInjectedKeysCheckBox.IsChecked()
config.conf["keyboard"]["multiPressTimeout"] = self.multiPressTimeoutEdit.GetValue()

Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ To use this feature, "allow NVDA to control the volume of other applications" mu
* Automatic language switching is now supported when using Microsoft Speech API version 5 (SAPI5) and Microsoft Speech Platform voices. (#17146, @gexgd0419)
* NVDA can now be configured to speak the current line or paragraph when navigating with braille navigation keys. (#17053, @nvdaes)
* In Word, the selection update is now reported when using Word commands to extend or reduce the selection (`f8` or `shift+f8`). (#3293, @CyrilleB79)
* From keyboard settings, the masking of passwords can be disabled so that real typed characters can be announced even in protected edit boxes (#17451, @nvdaes)

### Changes

Expand Down
5 changes: 5 additions & 0 deletions user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,11 @@ When enabled, NVDA will announce all non-character keys you type on the keyboard
When enabled, a short buzzer sound will be played when a word you type contains a spelling error.
This option is only available if reporting of spelling errors is enabled in NVDA's [Document Formatting Settings](#DocumentFormattingSettings), found in the NVDA Settings dialog.

##### Mask passwords while typing {#MaskPasswordsWhileTyping}

If this option is enabled, while typing in a protected edit box such as a password field, NVDA will mask typed characters while typing, reporting "start" instead of the actual typed character.
This option is on by default, but people who has difficulties using the keyboard may would like to turn it off, so that real typed characters can be reported even in protected fields.

##### Handle keys from other applications {#KeyboardSettingsHandleKeys}

This option allows the user to control if key presses generated by applications such as on-screen keyboards and speech recognition software should be processed by NVDA.
Expand Down

0 comments on commit 4a29866

Please sign in to comment.