Changes between Version 1 and Version 2 of DevelopersGuide/HelpSystem


Ignore:
Timestamp:
2009-11-08T16:56:29+01:00 (16 years ago)
Author:
Gubaer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DevelopersGuide/HelpSystem

    v1 v2  
    11= Context-sensitive help =
     2[[TOC(inline)]]
    23
    34== Help content ==
     
    2122    * {{{/Dialog/LayerDialog}}} - help topic for the help content about the layer dialog
    2223
     24
     25
    2326== Enabling context-sensitive help ==
    2427=== Declaring help topics ===
     
    2730Always 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].
    2831
    29 === Adding a help button to an UI ===
     32=== Adding a help button to an UI widget ===
    3033You 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]:
    3134{{{
     
    7174
    7275At 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 ===
     78You 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
     82import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
     83
     84// Example: a custom action with a declared help topic
     85//
     86class 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//
     98JButton btn = nwe JButton(new MyAction());
     99}}}
     100
    73101
    74102=== Context-sensitive help for the ExtendedDialog ===