[B4X] [XUI] SwiftButton

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime User

Attachments

  • test.gif
    test.gif
    16.5 KB · Views: 2,545
Last edited:

jahswant

Well-Known Member
Licensed User
Longtime User
It look 10k times more simpler than the platform specific library. XUI hummmmmm nice.
 

incendio

Well-Known Member
Licensed User
Longtime User
What's the minimum B4J version to run this sample?

Tried it in B4J 6.01, got an error :

Unknown member drawpath.
 

DonManfred

Expert
Licensed User
Longtime User

rraswisak

Active Member
Licensed User
Longtime 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
 

rraswisak

Active Member
Licensed User
Longtime 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.
Yes you are right, this is what i have done:

1. Add this at p_Touch sub right before Select Action code
B4X:
 If mBase.Enabled=False Then Return

2. Add this at Draw sub right before If pressed = False Then code
B4X:
If mBase.Enabled=False Then
   clr1 = Colors.Gray
   clr2 = Colors.DarkGray
   pressed=False
End If
 

JdV

Active Member
Licensed User
Longtime User
Hi

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.

Regards

Joe
 

Alberto Michelis

Well-Known Member
Licensed User
Longtime 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?
Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

rraswisak

Active Member
Licensed User
Longtime User
just modify this code to raise click event only if touch_up position inside the button:
B4X:
Private Sub p_Touch (Action As Int, X As Float, Y As Float)
   If mBase.Enabled=False Then Return
   Select Action
       Case mBase.TOUCH_ACTION_DOWN
           pressed = True
           Draw
       Case mBase.TOUCH_ACTION_UP
           pressed = False
           Draw
           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 & "_Click")   
           End If
   End Select
End Sub
 

Mashiane

Expert
Licensed User
Longtime User
I wanted to SetLatoutAnimated to this button component, here we go..

B4X:
Sub AnimateSwiftButton(b As SwiftButton, Duration As Int, newTop As Int)
    Dim base As B4XView = b.mBase 
    Dim left As Int = base.left
    Dim height As Int = base.Height
    Dim width As Int = base.width
    base.SetLayoutAnimated(Duration, left, newTop, width, height)
End Sub
 
Status
Not open for further replies.
Top