B4J Question Is it possible to add a tool tip to menu items?

miker2069

Active Member
Licensed User
Longtime User
The title says it all - is there a way to add tool tip information to a menu item either via the json string or programmatically?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The standard menu items do not support this feature.

You can use this code to create custom menu items:
B4X:
Sub CustomMenu_MouseClicked (EventData As MouseEvent)
   Dim lbl As Label = Sender
   Log($"Clicked: ${lbl.Text}"$)
End Sub

Sub CreateCustomMenuItem (Text As String, Tooltip As String) As MenuItem
   Dim lbl As Label
   lbl.Initialize("CustomMenu")
   lbl.Text = Text
   lbl.TooltipText = Tooltip
   Dim CustomMenuItem As JavaObject
   CustomMenuItem.InitializeNewInstance("javafx.scene.control.CustomMenuItem", Array(lbl))
   Return CustomMenuItem
End Sub

Usage:
B4X:
Dim FileMenu As Menu = MenuBar1.Menus.Get(0)
FileMenu.MenuItems.Add(CreateCustomMenuItem("Custom Text", "Custom Tooltip"))
FileMenu.MenuItems.Add(CreateCustomMenuItem("Custom Text2", "Custom Tooltip2"))

SS-2017-09-24_08.27.16.png
 
Upvote 0
Top