Example 3.1. Contextual menus
The example below is pretty useless however it shows how contextual menus can be implemented. It displays a special popup menu when some text is selected and the normal Edit popup menu otherwise.
<command name="contextualMenu">
<macro>
<choice>
<sequence>
<test expression="$selectedChars != ''" />
<command name="contextualMenu1" />
</sequence>
<command name="editMenu" />
</choice>
</macro>
</command>
<command name="contextualMenu1">
<menu>
<item label="To Upper Case"
icon="contextualmenus_icons/to_upper_case.gif"
command="convertCase" parameter="upper" />
<item label="To Lower Case"
icon="contextualmenus_icons/to_lower_case.gif"
command="convertCase" parameter="lower" />
<item label="Capitalize Words"
command="convertCase" parameter="capital" />
<editMenu />
</menu>
</command>
<binding>
<mousePressed button="3"/>
<command name="contextualMenu" />
</binding>