A percent string is a string which is not used literally but first processed before use if it starts with a percent sign '%'. What kind of processing is done depends on the the percent sign following character. This processing possibly changes also other aspects of a widget (e.g. not only sets the text of a menu item but also adds a icon and a shortcut).
The following percent prefixes are used in this gnocl version. Others are reserved for future use.
%% | Percent sign and rest of string without change. |
---|---|
%! | Rest of string without change. |
%_ | Rest of string with the first underline character '_' removed and the following character underlined and used as accelerator. |
%# | The rest of the string with first underline character removed is used as identifier for a standard widget or icon. For a menu item the icon and shortcut is used. The string is used as text with the character after the first underline character underlined and used as accelerator. |
%/ | Rest of string is used as file name (e.g. for use in the toolbar widget to load an icon). |
The idea behind the percent string is to bundle all information in one place. This is especially usefull if text with accelerators are translated, e.g. "_Open" is Open with 'o' as accelerator. If the string "_Open" is mapped to "Ö_ffnen" for german language, the widget becomes Öffnen with 'f' as accelerator if this language is chosen.
"%% a percent" | -> | "% a percent" |
"%!_li_te_ral" | -> | "_li_te_ral" |
"%#Q_uit" | -> | for a menu item: "Quit" + accelerator 'u' + standard shortcut + standard icon |
"%__File" | -> | for a menu item: "File" + accelerator 'f' |