© Cerilica 2020-2022

A module that adds two modern features to Wimp menus.

The current version is 0.02 (23 Mar 2022) [32bit] (docs updated 7 May 2022)

The MenuBadges module enables Wimp menu entries to bear a Badge in the left margin, and for writable entries to have a text Postfix on the right:

A menu featuring lots of Menu Badges and an Input Postfix

Menu Badges are a common feature of many other GUI toolkits, so it’s about time RISC OS gained them. And although writable entries in menus are rather archaic, being able to add a textual Postfix makes them more useful, especially when it’s a unit.

There is extensive documentation in the above zip, but here are the SWIs.

The module provides two main SWIs, and a couple of convenience calls:

(07 May 2022) – I have fixed a typo in this documentation (and also in the zip file) but the module and demo program are unchanged.

MenuBadges_Create (&5A300)

=> R0 sprite area ptr (or 0)

This is called immediately after Wimp_CreateMenu or Wimp_CreateSubMenu if the menu is to contain Badges.

Badges are typically 16×16 pixel sprites (up to 22×22 is possible) in your own sprite area. If R0 is zero, the Wimp sprites are used, but that is not recommended.

Any entry that is to have a Badge must be indirected text, with a Validation String containing a Sprite name. It’s as easy as that.

MenuBadges_CreateMenu (&5A301)

=> R1 menu definition
R2 x
R3 y
R4 sprite area ptr (or 0)

This is a convenience function that calls Wimp_CreateMenu and then MenuBadges_Create.

MenuBadges_CreateSubMenu (&5A302)

=> R1 menu definition
R2 x
R3 y
4 sprite area ptr (or 0)

This is a convenience function that calls Wimp_CreateSubMenu and then MenuBadges_Create.

MenuBadges_Postfix (&5A303)

=> R1 entry number (first is 0)
R2 string,ctrl (must exist as long as the menu does)
R3 width, or 0 for automatic

Called after Wimp_Create[Sub]Menu this adds a textual postfix to a writable menu entry. Typically R3 is zero, but if the menu contains multiple writables, the same width can be passed in all calls to ensure the postfixes align.

Note that the Postfix always appears to the right of the input, even when the menu goes right-to-left. This is because it is intended for units on numeric fields.

MenuBadges and Postfixes work in right-to-left menus too