Bug #3574

Multiple actions have Ctrl+F3 accelerator assigned

Added by mccartney 10 months ago. Updated 10 months ago.

Status:New Start date:07/15/2011
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:GUI
Target version:-
Revision:14630 Resolution:

Description

Steps to reproduce:
  1. Open the File | Backup menu
Observed:
  1. Both "Backup" and "Backup linklist" actions have Ctrl+F3 accelerator keystroke assigned

The same problem applies to other actions (discovered by tracking java.lang.NoSuchFieldException in YourKit Java Profiler):

+----------------------------------------------------------------------------------------+------------+                          
|                                          Name                                          |   Count    |                          
+----------------------------------------------------------------------------------------+------------+                          
|  +---java.lang.Class.getField(String)                                                  |  8  100 %  |                          
|    |                                                                                   |            |                          
|    +---jd.gui.action.JDAction.setAccelerator(String)                                   |            |                          
|      |                                                                                 |            |                          
|      +---jd.gui.swing.jdgui.actions.ToolBarAction.<init>(String, String, String, int)  |            |                          
|        |                                                                               |            |                          
|        +---jd.gui.swing.jdgui.actions.ToolBarAction.<init>(String, String, String)     |            |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.AddUrlAction.<init>()                     |  1   13 %  |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.BackupAction.<init>()                     |  1   13 %  |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.BackupLinkListAction.<init>()             |  1   13 %  |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.CleanupDownloads.<init>()                 |  1   13 %  |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.CleanupPackages.<init>()                  |  1   13 %  |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.ExitAction.<init>()                       |  1   13 %  |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.KnowledgeAction.<init>()                  |  1   13 %  |                          
|          |                                                                             |            |                          
|          +---jd.gui.swing.jdgui.menu.actions.LatestChangesAction.<init>()              |  1   13 %  |                          
+----------------------------------------------------------------------------------------+------------+   

Screenshot.png (67.4 kB) mccartney, 07/15/2011 11:57 pm

Screenshot-2.png (55 kB) mccartney, 07/15/2011 11:57 pm

History

Updated by mccartney 10 months ago

I've debugged the issue a bit and here are my findings:
- as indicated in the stacktraces above, the keystrokes are assigned to actions in the JDAction.setAccelerator() method
- the keystroke is defined based on value of accelerator key in the translation files as determined by createAccelerator() methods defined in subclasses
- for some of the actions (namely the 8 listed above) the translation doesn't exist in the required file (at least for the English language), so the usual fallback mechanism kicks in. When requesting translation for an unknown key, the name of the key is returned
- so the input for constructing keystrokes for these 8 actions is something like: "GuiTranslation.ion_backuplinklist_accelerator", which is not handled by the try {} section in JDAction.setAccelerator()
- consequently the control goes to the catch section in this method, which creates the Keystroke instance using the last letter of the accelerator - here often it's 'r'.
- The Keystroke class expects a key code as defined by VK_ codes in the KeyEvent class. The letter 'r' is the code 114DEC = 72HEX, which is exactly the same value as VK_F3
- and standard modifier for menus adds the usual Ctrl

This is how we end up with Ctrl+F3.

I am not sure what should be the solution:
- Should the code there look into different language file (currently it looks into GuiTranslation, but these accelerators are defined in en.loc in jd/languages)?
- or should the accelerators definitions be moved from en.loc to GuiTranslation.en.lng?

(the same of course applies to other languages)

Also available in: Atom PDF