B4J Question Menus in the internal designer are declared as JSON strings.

strupp01

Active Member
Licensed User
Longtime User
Is there the possibility to display one or more of the displayed actions as bold?
For example:
upload_2017-9-2_12-18-50.jpeg
 

Attachments

  • upload_2017-9-2_12-17-29.jpeg
    upload_2017-9-2_12-17-29.jpeg
    8.7 KB · Views: 151

rwblinn

Well-Known Member
Licensed User
Longtime User
See attached example.
Solution
The menubar menuitems JSON string must contain an unique tag per menuitem:
B4X:
{Text: "_Save", Tag:"FileSave", EventName: "FileSave"},

The menuitems are collated in a global map. The menuitem to change is determined by its tag.
In a subroutine, the menuitem style is changed using the setStyle API menthod (requires the JavaObject library).
B4X:
Private Sub MenuItemBold(MenuTag As String)
    Dim mi As MenuItem = MenuItems.Get(MenuTag)
    If mi.IsInitialized Then
        Dim joMI As JavaObject = mi
        joMI.RunMethod("setStyle", Array("-fx-font-weight: bold;"))
    End If
End Sub
In the attached example, menu file > save is set to bold
B4X:
MenuItemBold("FileSave")

upload_2017-9-2_18-6-12.png


Hints
If other menuitem types, like a checkmenuiten, then add or change the sub accordingly.
Other styles are also possible, like setting the font to red ("-fx-text-fill:red") etc.
 

Attachments

  • meniitembold.zip
    2 KB · Views: 178
Upvote 0
Top