Downstate in code

Mickster

Active Member
Licensed User
Longtime User
I'm developing a counter in my app that simulates a flip clock:
http://www.ladidah.com.au/range/images/flip-clock-grey.jpg
(This is what they look like).

I have buttons on either side of the clock that increase or decrease the individual integers of the counter. I imported the numbers 0-9 as bitmaps and I also imported a 'downstate' which is a single frame that makes the counter appear to 'flip'. The numbers are just panels, so they don't have downstates, so I used the button_down routine to create this effect:

B4X:
Sub btnIncrement_Down
   
   Dim b As Button
   b = Sender
   pnlInteger(b.Tag).SetBackgroundImage(bmpNumDown)
      
End Sub

When the button click routine is run, the downstate image is replaced by the image of the next number. This works well, until you accidentally call the down routine and miss the click routine. For example, if the user presses the button, and then slides their finger off the button before releasing, the image remains as the downstate. I tried to fix this by simply scrapping the click routine and using button_up. However, this causes a lot of flickering with the images.

Does anyone have any thoughts on how I could achieve this intermediate frame effect?

Thanks
 

thedesolatesoul

Expert
Licensed User
Longtime User
For example, if the user presses the button, and then slides their finger off the button before releasing, the image remains as the downstate.

While I dont completely understand the problem, I picked the solution to the above quoted from Informatix's tutorials.

In Action_MOVE you can add:
B4X:
If X < 0 OR X > pnl.Width OR Y < 0 OR Y > pnl.Height Then
to cancel the action and return to normal state.
 
Upvote 0

Mickster

Active Member
Licensed User
Longtime User
Sorry, I was trying to explain without making it long winded.

I'll try again without the confusing context.

Essentially, I have a panel that has a background image. When I press a button, the background image changes. I want an intermediate background on the panel that appears when the button is touched, not clicked. The btn_down routine works, but if the user doesn't complete the press (holds their finger on the screen but moves it off the button) to call the btn_click routine, the new image doesn't get displayed and the intermediate is left.

Can a button capture a touch event?
 
Upvote 0
Top