Disable buttons temporarily possible using AHViewPager?

NFOBoy

Active Member
Licensed User
Longtime User
Ok, so AHViewPager is Great at quickly building pages that can use different views and scroll smoothly between pages

My first program used a ClearPanel On top that I had to use the Gestures Listener, and then pass events to views below based on user actions.

However, it was also very easy for me to Disable user clicks after they had pushed a view on my screen, until the view was finished doing what it needed to do (usually load a sound file and play it)

This was done by just setting a global boolean to True when the view is first sent a click event, and set to False when the view code is finished.

Any further Gestures actions recieved during the True time are immediatly rejected.
However, I cannot get this same functionality to occur with AHViewPager.

I can get it to work on initial loading of the page, so that an animation can be used after adding the AHViewPager to the activivity, (ICOS animations) by setting a global so that views check that global variable first before continuing... and the animation end trips the variable so that views will run their code.

But

When I change the global variable in the code (or try to add a clear panel above all others to intercepts click events) the user can still "push ahead" and have other views activate prior to current view finishing code.

So the code below... does not stop another btn_click from occuring...


B4X:
Sub btn_click
If IgnoreResponse Then 
 Return
End If

IgnoreResponse=True
DoEvents
... code to do animations or  play sounds
DoEvents
IgnoreResponse = False
end sub

Am I missing something obvious?

Thanks!

Ross
 

NFOBoy

Active Member
Licensed User
Longtime User
Erel,

thanks much... I tried that and kept :BangHead: as it was still passing along.

What I did to get it to finally work, was add a timer event to fire off the audio portions... so that the code module for the Button Click was complete soon after starting the audio... instead of the audio being done inside the module itself.

Still don't understand completely, but I think that is because the system grabs the next touch event, and then it won't send it to a Btn_click event (or any other touch event) until AFTER the btn click event is finished completely.

So now code is this

B4X:
Sub Globals
 Dim tmrEnd as Timer 'do the initialization and length for tick in Activity_Create 
end sub


Sub btn_click
  If IgnoreResponse Then 
       Return
  End If
  IgnoreResponse=True
  ...code to start animations or  play sounds
  tmrEnd.enabled = True
end sub

sub tmrEnd_click
  If animationOrSoundDone then
    IgnoreResponse = False
    tmrEnd.enabled=False
  end if
end sub
 
Upvote 0
Top