Ticket #21148: JOSM-context-help.diff
| File JOSM-context-help.diff, 1.7 KB (added by , 5 years ago) |
|---|
-
core/src/org/openstreetmap/josm/actions/HelpAction.java
9 9 import java.awt.event.KeyEvent; 10 10 import java.util.Optional; 11 11 12 import javax.swing.MenuElement; 13 import javax.swing.MenuSelectionManager; 12 14 import javax.swing.SwingUtilities; 13 15 14 16 import org.openstreetmap.josm.gui.MainApplication; … … 50 52 public void actionPerformed(ActionEvent e) { 51 53 if (e.getActionCommand() == null) { 52 54 String topic; 53 if (e.getSource() instanceof Component) { 55 MenuElement[] menuPath = MenuSelectionManager.defaultManager().getSelectedPath(); 56 if (menuPath.length > 0) { 57 // Get help topic from last element in selected menu path (usually a JMenuItem). 58 // If a JMenu is selected, which shows a JPopupMenu, then the last path element 59 // is a JPopupMenu and it is necessary to look also into previous path elements. 60 topic = null; 61 for (int i = menuPath.length - 1; i >= 0; i--) { 62 Component c = menuPath[i].getComponent(); 63 topic = HelpUtil.getContextSpecificHelpTopic(c); 64 if (topic != null) { 65 break; 66 } 67 } 68 } else if (e.getSource() instanceof Component) { 54 69 Component c = SwingUtilities.getRoot((Component) e.getSource()); 55 70 Point mouse = c.getMousePosition(); 56 71 if (mouse != null) {
