/* The serial ID of the last context menu to be displayed. */
public static int lastMenuEventSerial;
+ /* The last group ID used for a menu item. */
+ public int lastGroupId;
+
private static class Item implements MenuItem.OnMenuItemClickListener
{
public int itemID;
public EmacsContextMenu subMenu;
public boolean isEnabled, isCheckable, isChecked;
public EmacsView inflatedView;
+ public boolean isRadio;
@Override
public boolean
checkable. Likewise, if ISCHECKED is set, make the item
checked.
- If TOOLTIP is non-NULL, set the menu item tooltip to TOOLTIP. */
+ If TOOLTIP is non-NULL, set the menu item tooltip to TOOLTIP.
+
+ If ISRADIO, then display the check mark as a radio button. */
public void
addItem (int itemID, String itemName, boolean isEnabled,
boolean isCheckable, boolean isChecked,
- String tooltip)
+ String tooltip, boolean isRadio)
{
Item item;
item.isCheckable = isCheckable;
item.isChecked = isChecked;
item.tooltip = tooltip;
+ item.isRadio = isRadio;
menuItems.add (item);
}
}
else
{
- menuItem = menu.add (item.itemName);
+ if (item.isRadio)
+ menuItem = menu.add (++lastGroupId, Menu.NONE, Menu.NONE,
+ item.itemName);
+ else
+ menuItem = menu.add (item.itemName);
menuItem.setOnMenuItemClickListener (item);
/* If the item ID is zero, then disable the item. */
if (item.isChecked)
menuItem.setChecked (true);
+ /* Define an exclusively checkable group if the item is a
+ radio button. */
+
+ if (item.isRadio)
+ menu.setGroupCheckable (lastGroupId, true, true);
+
/* If the tooltip text is set and the system is new enough
to support menu item tooltips, set it on the item. */
"Lorg/gnu/emacs/EmacsContextMenu;");
FIND_METHOD (add_item, "addItem", "(ILjava/lang/String;ZZZ"
- "Ljava/lang/String;)V");
+ "Ljava/lang/String;Z)V");
FIND_METHOD (add_submenu, "addSubmenu", "(Ljava/lang/String;"
"Ljava/lang/String;Ljava/lang/String;)"
"Lorg/gnu/emacs/EmacsContextMenu;");
(jboolean) !NILP (enable),
(jboolean) checkmark,
(jboolean) !NILP (selected),
- help_string);
+ help_string,
+ (jboolean) (EQ (type,
+ QCradio)));
android_exception_check ();
if (title_string)