diff options
| author | Po Lu <luangruo@yahoo.com> | 2023-07-20 11:21:25 +0800 |
|---|---|---|
| committer | Po Lu <luangruo@yahoo.com> | 2023-07-20 11:21:25 +0800 |
| commit | 7e8904e796807e3b8bfc20ed45135c53d8a86f50 (patch) | |
| tree | ce88ecb39d19e0f677989b80ad908611831b47e5 /java/org/gnu/emacs/EmacsContextMenu.java | |
| parent | 4d3442ebad5cb1e1005cd5eca7e91c95e767ed65 (diff) | |
Use context menu header titles on Android
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
New field `title'.
(addSubmenu): New arg TITLE. Set that field.
(expandTo): Set MENU's header title if it's a context menu.
* src/androidmenu.c (android_init_emacs_context_menu): Adjust
signature of `createContextMenu'.
(android_menu_show): Use TITLE instead of pane titles if there's
only one pane.
Diffstat (limited to 'java/org/gnu/emacs/EmacsContextMenu.java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsContextMenu.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/java/org/gnu/emacs/EmacsContextMenu.java b/java/org/gnu/emacs/EmacsContextMenu.java index eb83016c849..46eddeeda3d 100644 --- a/java/org/gnu/emacs/EmacsContextMenu.java +++ b/java/org/gnu/emacs/EmacsContextMenu.java @@ -27,6 +27,7 @@ import android.content.Intent; import android.os.Build; +import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -130,18 +131,27 @@ public final class EmacsContextMenu } }; + /* List of menu items contained in this menu. */ public List<Item> menuItems; + + /* The parent context menu, or NULL if none. */ private EmacsContextMenu parent; + /* The title of this context menu, or NULL if none. */ + private String title; + + + /* Create a context menu with no items inside and the title TITLE, which may be NULL. */ public static EmacsContextMenu - createContextMenu () + createContextMenu (String title) { EmacsContextMenu menu; menu = new EmacsContextMenu (); + menu.title = title; menu.menuItems = new ArrayList<Item> (); return menu; @@ -204,7 +214,7 @@ public final class EmacsContextMenu item.itemID = 0; item.itemName = itemName; item.tooltip = tooltip; - item.subMenu = createContextMenu (); + item.subMenu = createContextMenu (itemName); item.subMenu.parent = this; menuItems.add (item); @@ -287,12 +297,22 @@ public final class EmacsContextMenu /* Enter the items in this context menu to MENU. Assume that MENU will be displayed in VIEW; this may lead to - popupMenu being called on VIEW if a submenu is selected. */ + popupMenu being called on VIEW if a submenu is selected. + + If MENU is a ContextMenu, set its header title to the one + contained in this object. */ public void expandTo (Menu menu, EmacsView view) { inflateMenuItems (menu, view); + + /* See if menu is a ContextMenu and a title is set. */ + if (title == null || !(menu instanceof ContextMenu)) + return; + + /* Set its title to this.title. */ + ((ContextMenu) menu).setHeaderTitle (title); } /* Return the parent or NULL. */ |
