Changes between Version 1 and Version 2 of DevelopersGuide/HelpSystem
- Timestamp:
- 2009-11-08T16:56:29+01:00 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevelopersGuide/HelpSystem
v1 v2 1 1 = Context-sensitive help = 2 [[TOC(inline)]] 2 3 3 4 == Help content == … … 21 22 * {{{/Dialog/LayerDialog}}} - help topic for the help content about the layer dialog 22 23 24 25 23 26 == Enabling context-sensitive help == 24 27 === Declaring help topics === … … 27 30 Always use the marker method [source:/trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java ht("...")] to declare a help topic. {{{ht}}} just replies the relative help topic. It's purpose is only to make explicit which string constants are used as help topics. There are scripts which harvest these help topics from the JOSM source and create a [wiki:/DevelopersGuide/HelpSystem/HelpTopicsList cross-references]. 28 31 29 === Adding a help button to an UI === 32 === Adding a help button to an UI widget === 30 33 You can easily add a help button to a GUI element. The easiest way is to reuse [source:/trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction ContextSensitiveHelpAction]: 31 34 {{{ … … 71 74 72 75 At run-time, JOSM walks up the ui component tree and redirects the user to the first, i.e. the most specific help topic it finds along this way. 76 77 === Context-sensitive help for an action === 78 You can easily configure context-sensitive help for an action. If you later add the action to a button or a menu item, both the button or the menu item will redirect the user to the declared help topic if he presses F1. 79 80 {{{ 81 #!java 82 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 83 84 // Example: a custom action with a declared help topic 85 // 86 class MyAction extends AbstractAction { 87 public MyAction() { 88 putValue("help", ht("/Action/MyAction")); // configure help topic for the action 89 } 90 91 public void actionPerformed(ActionEvent evt) { 92 // tbd 93 } 94 } 95 96 // btn will respond to F1. Help topic is /Action/MyAction 97 // 98 JButton btn = nwe JButton(new MyAction()); 99 }}} 100 73 101 74 102 === Context-sensitive help for the ExtendedDialog ===