Skip to content

Keyboard Shortcuts: "Black and White" incorrectly shares the "View" shortcut #900

Description

@sheerazzeb-lab

Describe the bug

In NAPS2, the View and Black and White actions cannot be assigned separate keyboard shortcuts.

When I assign a keyboard shortcut to View under:

Settings → Keyboard Shortcuts

the same shortcut is automatically assigned to Black and White.

Likewise, if I assign a different shortcut to Black and White, the shortcut assigned to View changes to the same key.

Therefore, both actions always end up with the same shortcut, and pressing the shortcut executes View instead of Black and White.

Steps to reproduce

  1. Open NAPS2.
  2. Go to Settings → Keyboard Shortcuts.
  3. Select View.
  4. Assign a shortcut, for example F8.
  5. Select Black and White.
  6. The shortcut is also shown as F8.
  7. Now assign F9 to Black and White.
  8. Return to View.
  9. It is now also assigned to F9.

The problem occurs in both directions.

Versions tested

The problem occurs in both versions.

Additional testing

I also tested this by manually editing the NAPS2 configuration file.

For example:

<KeyboardShortcuts>
    <ImageView>Ctrl + Divide</ImageView>
    <ImageBlackWhite>Ctrl + Subtract</ImageBlackWhite>
</KeyboardShortcuts>

After opening Settings → Keyboard Shortcuts, NAPS2 displays Ctrl + Divide for both View and Black and White.

This indicates that the problem is not simply an invalid keyboard shortcut or an XML formatting issue.

Possible cause

I inspected the NAPS2 source code and found what appears to be the cause in KeyboardShortcutsForm.cs.

The entries for View and Black and White currently use the same configuration property:

new(UiStrings.View, c => c.KeyboardShortcuts.ImageView),
new(UiStrings.BlackAndWhite, c => c.KeyboardShortcuts.ImageView),

The second line appears to be incorrect. It should presumably be:

new(UiStrings.View, c => c.KeyboardShortcuts.ImageView),
new(UiStrings.BlackAndWhite, c => c.KeyboardShortcuts.ImageBlackWhite),

Interestingly, the actual desktop shortcut registration appears to treat the two actions separately:

_ksm.Assign(ks.ImageBlackWhite, commands.BlackWhite);
...
_ksm.Assign(ks.ImageView, commands.ViewImage);

Therefore, the problem appears to be specifically in the Keyboard Shortcuts settings UI, where the Black and White entry incorrectly references ImageView.

Expected behavior

View and Black and White should be independently configurable, for example:

  • F8 → View
  • F9 → Black and White

Changing one should not change the other.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions