Hi again Daniel,

I took the time to implement a few methods that should help you.

First, you can add the two following functions to GuiMap :
  public String getLabelWithoutMnemonic(String label) {
    if (label == null) {
      return null;
    }
    int index = label.indexOf('&');
    if (index == -1) {
      return label;
    }
    return
      label.substring(0, index) +
      ((index < label.length() - 1) ? label.substring(index + 1) : "");
  }
 
  public char getMnemonic(String label) {
    if (label == null) {
      return ' ';
    }
    int index = label.indexOf('&');
    if ((index == -1) || (index == label.length() - 1)){
      return ' ';
    }
    return label.charAt(index + 1);
  }

You can then modify the newXXX() methods of GuiMap. For example, for newJMenuItem():
  JMenuItem newJMenuItem(String key) {
    String label = getLabel(key);
    return new KeyJMenuItem(key, getLabelWithoutMnemonic(label), getMnemonic(label));
  }

And also modify the corresponding KeyJMenuItem constructor:
    KeyJMenuItem(String key, String label, char mnemonic) {
      super(label);
      if (mnemonic != ' ') {
        setMnemonic(mnemonic);
      }
      this.key = key;
      map.put(key, this);
    }

After this, you may have to do some cleaning in Jmol.java.

I haven't tested the code, I hope it works.
I can answer questions until tomorrow in the beginning of the afternoon (French time), I am leaving on holidays afterwards :)

Regards,
Nicolas


Daniel Leidert wrote:
Hello all,

(bcc to Egon)

I have a little problem, I hope you can solve. Following the
*.properties files in Jmol, the menu includes mnemonics. Now the problem
is, I would like to have them inside the translatable string, e.g.:

_File
&File

where the "_" or "&" marks the mnemonic-char. This is because e.g.
"File" is translated, but the mnemonic is "F". But in the German
translation "File"="Datei" and the "F" cannot be the mnemonic. An
example on how to extract the mnemonic can be found at
http://www.koders.com/java/fid4286AE64065F639100053D2AF7BD618E87A0DAD4.aspx in line 225.

My idea: Instead of reading the mnemonic from the .properties file(s),
src/org/openscience/jmol/app/GuiMap.java should contain the functions
to 

a) find the mnemonic in a string and add it to a menu item
b) remove the mnemonic-char (& or _) from the string for the menu entry

E.g. GT._("&File") should return a string "&Datei". Then this string
should be examined.

IMHO it affects src/org/openscience/jmol/app/GuiMap.java and
src/org/openscience/jmol/app/Jmol.java (protected JMenuItem
createMenuItem()). It should not affect any other fle/function.

What do you think about this? Is it possible? If yes, could you
implement it (my Java knowledge was not good enough to implement it).

Reply via email to