press and hold button?

techknight

Well-Known Member
Licensed User
Longtime User
Is it possible to press and hold a command button?

What I want to do is when i press and hold a command button, the app does one thing. Soon as I release the button, the app does something else.

Is this possible?
 

Mahares

Expert
Licensed User
Longtime User
Are you looking for something like this?
B4X:
dim B1 as Button
B4X:
Sub B1_Down
   Msgbox("You are holding me down. Please let go","")
End Sub
B4X:
Sub B1_Up
   Msgbox("I am glad you let go. Thanks. I was suffocating","")
End Sub
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
That would work!

Edit: Crap. Doesnt work with menubuttons.

Edit: Tried it with a command button, it works somewhat. It doubletriggers up while holding down though. Which is not good, and wont work for my application.

If i hold down the command button, I have a toastmessage that shows Down. Well itll show Down, then Up, then Down. While holding the button. Odd. Let loose, itll show Up, Sometimes Down, then Up.
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I see what you mean. Try using btn_click instead of btn_up and enable a timer in order to do whatever needed in the mean time.
About menuItems, I don't think this is possible with normal coding.
That would work!

Edit: Crap. Doesnt work with menubuttons.

Edit: Tried it with a command button, it works somewhat. It doubletriggers up while holding down though. Which is not good, and wont work for my application.

If i hold down the command button, I have a toastmessage that shows Down. Well itll show Down, then Up, then Down. While holding the button. Odd. Let loose, itll show Up, Sometimes Down, then Up.
 
Upvote 0
Top