B4A Library [B4X] [XUI] HexMenu

Status
Not open for further replies.
Cross platform hexagons menu implemented as a custom view:

pQtXvSJZQ0.gif


Can show up to 7 items.

B4A project is attached. Class is supported by B4J and B4i as well. Depends on XUI and BitmapCreator libraries.

Example with gradient stroke:

i_view64_Ihv7fjyBRn.png

Version with gradient stroke: https://www.b4x.com/android/forum/threads/b4x-xui-hexmenu.112410/#post-700941
 

Attachments

  • HexMenu.zip
    11 KB · Views: 768
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
I've just had a quick search for icons to place directly into this menu, @Erel this has some great potential. I have some more iOS learning to complete but it does look like menu will definitely be making its way into a project near me sooner rather than later :)

B4X:
Sub Globals
    Private XUI As XUI
    Private HexMMain As HexMenu
    Private GD As GradientDrawable
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Menu")
    Activity.Title = "HEX Menu"

    Dim TopColor As Long = 0xFFFF7DE1 '0xFF1798A2
    Dim BottomColor As Long = 0xFFFFED8C '0xFFECF0BC
    GD.Initialize("TOP_BOTTOM", Array As Int(TopColor, BottomColor))
    Activity.Background = GD

    For Each lbl As B4XView In HexMMain.labels
        lbl.Font = XUI.CreateFontAwesome(16)
    Next

    Dim Imaages() As Object = Array As Object(Chr(0xF15C), Chr(0xF0F6), Chr(0xF0C0), Chr(0xF07A), Chr(0xF15A), Chr(0xF0D6), Chr(0xF080))
    Dim Options() As String = Array As String("Invoice", "Quote", "Contacts", "Stock", "Sales", "Payments", "Charts")

    For i = 0 To 6
        HexMMain.Items.Add($"${Imaages(i)}${CRLF}${Options(i)}"$)
    Next
    HexMMain.Update
End Sub

Android = Fonts too small, but you get the gist
Android.png


iPhone - No icons, but it's still looking good
iOS.png



Thank you...
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I had understood a different thing, how to set an image on the background of the entire menu (to do this you have to "work" on the basic panel).

You can make Items transparent by setting their color to Transparent

View attachment 90085

Set Fill Color to Transparent.
I added getBase property to the HexMenu (changed to version: 2.11, included in the project attached):
Clipboard01.png
 

Attachments

  • HexMenuTest.zip
    402.3 KB · Views: 263

Yafuhenk

Active Member
Licensed User
Longtime User
Is it possible to have a long_click/double_click in this hexmenu? I had a look at the sub Pnl_touch but I could only find TOUCH_ACTION_DOWN, TOUCH_ACTION_UP and TOUCH_ACTION_MOVE.
 

james_sgp

Active Member
Licensed User
Longtime User
Is it possible to use CSBuilder to get better icons/text? I tried but doesn`t seem to be doing anything....
B4X:
    dim cs1 as csbuilder
    cs1.Initialize.Size(20).Typeface(Typeface.DEFAULT)
    cs1.Alignment("ALIGN_CENTER").color(Colors.RGB(62,62,62)).Typeface(Typeface.FONTAWESOME).Append(Chr(0xF1D8)).Append(CRLF)
    cs1.Alignment("ALIGN_CENTER").Size(20).color(Colors.RGB(107,142,35)).Append("VERIFY")
    cs1.popall

    adv_hex_menu.Items.AddAll(Array As String(cs1, "1","2","3","4","5","6"))
 

james_sgp

Active Member
Licensed User
Longtime User
Tried it and I got no change in font size or color; as defined by the CSbuilder string...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Just tried with:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")
    For i = 1 To 10
        Dim cs As CSBuilder
        HexMenu1.Items.Add(cs.Initialize.Size(i * 3).Append("test").PopAll)
    Next
    HexMenu1.Update
End Sub

Sub HexMenu1_Click (Index As Int, Text As Object) 'change type to object
    Activity.Title = Text
End Sub

1605428663432.png
 

james_sgp

Active Member
Licensed User
Longtime User
Erel,

Thanks, i`ll try building the CS within the menu and see command.

James
 

james_sgp

Active Member
Licensed User
Longtime User
I tried Erel suggestion and it displays the menu as I want, but I`m getting an error (attached is a sample of the code that gives me this error)

hexmenu$ResumableSub_Pnl_Touchresume (java line: 445)
java.lang.Exception: Sub hexmenu1_click signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:215)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1045)
at b4a.example.hexmenu$ResumableSub_Pnl_Touch.resume(hexmenu.java:445)
at b4a.example.hexmenu._pnl_touch(hexmenu.java:288)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA$1.run(BA.java:352)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
 

Attachments

  • hex_menu_error.zip
    16.8 KB · Views: 219
Status
Not open for further replies.
Top