Button Down in Code

TomDuncan

Active Member
Licensed User
Longtime User
Hi All,
I am using the Calendar (or Kalender) and I need to show which day was pressed. In Delphi I would just hold that button in a key pressed state.
How can I do this in b4a?

My Calendar is visible on screen with database action happening with day changes.

Tom
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Maybe you should use a ToggleButton instead of a regular button.

You can however do it with the help of the reflection library:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   b.Initialize("b")
   Activity.AddView(b, 0, 0, 100, 100)
   SetPressed(b, True)
End Sub

Sub SetPressed(Btn As Button, Pressed As Boolean)
   Dim r As Reflector
   r.Target = b
   r.RunMethod2("setPressed", Pressed, "java.lang.boolean")
End Sub
 
Upvote 0

TomDuncan

Active Member
Licensed User
Longtime User
Thanks for that used Toggle Button
Only thing I needed to do was increase the button size.
Seems as though 50 is the min with for the toggle button.
The checked gree bar must be a fixed with, not in proportion to the with of the button.


Tom
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…