B4A Library [B4X] [XUI] SwiftButton

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jul 17, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Attached Files:

    Last edited: Jan 3, 2019
    GMan, jmon, Multiverse app and 21 others like this.
  2. Gabriel Loria Salmeron

    Gabriel Loria Salmeron Member Licensed User

    Thank you Erel. It looks great!
  3. MarcoRome

    MarcoRome Expert Licensed User

  4. jahswani

    jahswani Active Member Licensed User

    It look 10k times more simpler than the platform specific library. XUI hummmmmm nice.
  5. incendio

    incendio Well-Known Member Licensed User

    What's the minimum B4J version to run this sample?

    Tried it in B4J 6.01, got an error :

    Unknown member drawpath.
  6. DonManfred

    DonManfred Expert Licensed User

    incendio and JakeBullet70 like this.
  7. rraswisak

    rraswisak Active Member Licensed User

    Thank you for this, apparently the Enabled property seem doesn't work.
    When Enabled property set to false the button should have grayed color and can not be clicked
  8. Erel

    Erel Administrator Staff Member Licensed User

    This is a custom drawn button. Nothing will happen unless it is implemented. The code is quite simple. It shouldn't be difficult to add a "disabled" state.
  9. rraswisak

    rraswisak Active Member Licensed User

    Yes you are right, this is what i have done:

    1. Add this at p_Touch sub right before Select Action code
    If mBase.Enabled=False Then Return
    2. Add this at Draw sub right before If pressed = False Then code
    If mBase.Enabled=False Then
       clr1 = 
       clr2 = 
    End If
    Erel likes this.
  10. JdV

    JdV Active Member Licensed User


    Is it possible to include states for focused and unfocused buttons with this library? (B4XView doesn't seem to have a FocusChanged event or something like a 'HasFocus' member.)

    This would be perfect for creating obvious navigation on things like Android TV.


  11. Erel

    Erel Administrator Staff Member Licensed User

    B4XView doesn't have any events of its own. You need to handle the native view events. In this case the view is a Panel or Pane. You will need to do some work to make it focusable.
  12. JdV

    JdV Active Member Licensed User

    Thanks for the quick reply.
  13. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    How can I use it in B4A? can it be used in TabStrip?
    Any way of use better lookin buttons or images to click on and go to an activity with B4A and designer?
  14. Erel

    Erel Administrator Staff Member Licensed User

    Add the module to your project and add the button as a custom view with the designer.


    Not sure that I understand this question. The code is available. You can modify it as you like.
  15. rraswisak

    rraswisak Active Member Licensed User

    just modify this code to raise click event only if touch_up position inside the button:
    Private Sub p_Touch (Action As Int, X As Float, Y As Float)
    If mBase.Enabled=False Then Return
    Select Action
               pressed = 
    Case mBase.TOUCH_ACTION_UP
               pressed = 
    If (mBase.Left + x) >= mBase.Left And (mBase.Left + x) <= (mBase.Left + mBase.Width) And _
                  (mBase.Top + y) >= mBase.Top 
    And (mBase.Top + y) <= (mBase.Top + mBase.Height) Then
                   CallSubDelayed(mCallBack, mEventName & 
    End If
    End Select
    End Sub
  16. Erel

    Erel Administrator Staff Member Licensed User

    A better implementation of this class is included in XUI Views library.
    rraswisak likes this.
  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