B4J Library [B4X] [XUI] jSD BottoMenu (with source code)

Discussion in 'B4J Libraries & Classes' started by Star-Dust, Feb 23, 2019.

  1. Star-Dust

    Star-Dust Expert Licensed User

    (Here for Android)
    (Here for iOS)

    iSD_BottoMenu


    Author: Star-Dust
    Version: 1.1
    • BottoMenu
      • Events:
        • Selected (Value As Int)
      • Fields:
        • BackGroundColor As Int
        • Position As Int
          ' set or get Position
      • Functions:
        • AddMenu (CharText As String, FontName As B4XFont) As String
        • Class_Globals As String
        • Clear As String
        • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
          Base type must be Object
        • Initialize (Callback As Object, EventName As String) As String
        • Invalidate As String
        • IsInitialized As Boolean
          Verifica se l'oggetto sia stato inizializzato.
        • TransitionAnimated (Duration As Int, FromBmp As B4XBitmap, ToBmp As B4XBitmap, ImageView AsB4XView) As ResumableSub

    upload_2019-2-23_9-0-23.png
     

    Attached Files:

    Last edited: Mar 4, 2019
  2. Star-Dust

    Star-Dust Expert Licensed User

    Code:
    Sub AppStart (Form1 As Form, Args() As String)
        MainForm = Form1
        MainForm.RootPane.LoadLayout(
    "Layout1"'Load the layout file.
        MainForm.Show
        
        BottoMenu1.AddMenu(
    Chr(0xF009),xui.CreateFontAwesome(18))
        BottoMenu1.AddMenu(
    Chr(0xF0CA),xui.CreateFontAwesome(18))
        BottoMenu1.AddMenu(
    Chr(0xF0EC),xui.CreateFontAwesome(18))
        BottoMenu1.AddMenu(
    Chr(0xF096),xui.CreateFontAwesome(18))
        BottoMenu1.AddMenu(
    Chr(0xF2C0),xui.CreateFontAwesome(18))
    End Sub

    'Return true to allow the default exceptions handler to handle the uncaught exception.
    Sub Application_Error (Error As Exception, StackTrace As StringAs Boolean
        
    Return True
    End Sub

    Sub BottoMenu1_Selected(Value As Int)
        
    Log(Value)
    End Sub
     
  3. Star-Dust

    Star-Dust Expert Licensed User

    I had forgotten to attach the source. :p Sorry.

    You can find it at post # 1
     
    OliverA likes this.
  4. giannimaione

    giannimaione Well-Known Member Licensed User

    it usually does not work!
    i click on botton icon bar, and it usually does not work.
    then maximize/riseze form and it work
     
  5. Star-Dust

    Star-Dust Expert Licensed User

    I do not understand :p
     
  6. RWK

    RWK Member Licensed User

    Hi,

    he meant that sometimes the Click Event doesn't appear anymore.

    Code:
    Private Sub Label_MouseClicked (EventData As MouseEvent)
        
    Dim B4XL As B4XView = Sender
        
    Dim I As Int = B4XL.Tag
        
    Dim Label_Width As Float = mBase.Width / ChrMenu.Size
        
    Dim W As Int=(I+0.5)*Label_Width-((ImageViewlSize+BorderSize)/2)
        
    Dim M As Map = ChrMenu.Get(I)
    'Added
        Log("Pos: "& EventData.X& ":" & EventData.Y)
    '-------
        Position=I
        Slct.SetLayoutAnimated(
    200,w,0,ImageViewlSize+BorderSize,ImageViewlSize+BorderSize)
        Sleep(
    200)
        Slct.RemoveAllViews
        Slct=GenerateViewSelected(M.Get(
    "CharText"),xui.Color_Black,M.Get("Font"))
        mBase.AddView(Slct,w,
    0,ImageViewlSize+BorderSize,ImageViewlSize+BorderSize)
        
        
    If xui.SubExists(mCallBack,mEventName & "_Selected",1Then CallSub2(mCallBack,mEventName & "_Selected",Position)
    End Sub
    After some Clicks on the Bar no more Label_MouseClicked Events occurs...
    Sometime one arrive....sometimes I have to resize the windows to make it work for some clicks again.

    Maybe this is somewhat more addressed to jXUI ? Don't know.

    Grüße
    Rainer
     
    giannimaione likes this.
  7. Star-Dust

    Star-Dust Expert Licensed User

    There is an error in the code, Create a new panel with the selected option but do not delete the old one that remains in transparency that absorbs and consumes click events

    Update the sub in this way (at post#1 I updated the example)
    Code:
    Private Sub Label_MouseClicked (EventData As MouseEvent)
        
    Dim B4XL As B4XView = Sender
        
    Dim I As Int = B4XL.Tag
        
    Dim Label_Width As Float = mBase.Width / ChrMenu.Size
        
    Dim W As Int=(I+0.5)*Label_Width-((ImageViewlSize+BorderSize)/2)
        
    Dim M As Map = ChrMenu.Get(I)
      
        Position=I
        Slct.SetLayoutAnimated(
    200,w,0,ImageViewlSize+BorderSize,ImageViewlSize+BorderSize)
        Sleep(
    200)
        Slct.RemoveViewFromParent
        Slct.RemoveAllViews
        Slct=GenerateViewSelected(M.Get(
    "CharText"),xui.Color_Black,M.Get("Font"))
        mBase.AddView(Slct,w,
    0,ImageViewlSize+BorderSize,ImageViewlSize+BorderSize)
      
        
    If xui.SubExists(mCallBack,mEventName & "_Selected",1Then CallSub2(mCallBack,mEventName & "_Selected",Position)
    End Sub
     
    Last edited: Mar 1, 2019
    mcqueccu and giannimaione like this.
  8. Star-Dust

    Star-Dust Expert Licensed User

    Update code rel. 1.1
     
  9. Star-Dust

    Star-Dust Expert Licensed User

    update rel 1.3 (post#1)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice