Page 2 of 4

Re: No way to prevent clicks on a button

Posted: Mon Jun 24, 2013 6:54 am
by Simon
Hi Friends,
Is this where one would use "cancel pendingMessages"?
Mag, it's more than just that line, you can see the full thing in the Dictionary.

Not sure if it's correct, Mark or J-Marc will correct me.

Simon

A way to prevent clicks on a button

Posted: Mon Jun 24, 2013 8:41 am
by Mark
Hi Simon,

No, pending mouse clicks don't appear in the pendingMessages, but your question is defnitely related. To solve the situation discussed in this thread, I'd probably use the send command. Assuming that there is a group and a circular progress indicator displayed icon in a button, this could work:

Code: Select all

on hideEverything
  show grp"Black background with progress indicator"
  show btn "Progress Indicator"
  // do the video recording here
  hide btn "Progress Indicator"
  send "showEverything" to me in 100 millisecs
  // 0 millisecs might work too
end hideEverything

on showEverything
  hide grp "Black background with progress indicator"
end showEverything
This way, any pending mouse clicks are caught by the black image control in group "Black background with progress indicator" before the showEverything handler runs. until that happens, showEverything is in the pendingMessages. On a desktop version of LiveCode, you could use the flushEvents command, but that's unavailable on iOS.

Kind regards,

Mark

Re: No way to prevent clicks on a button

Posted: Mon Jun 24, 2013 8:58 am
by Simon
How about an:
on mouseUp
--do nothing
end mouseUp
in the Black grp/image script?
Would that capture the clicks and dismiss them?

Simon

Re: No way to prevent clicks on a button

Posted: Mon Jun 24, 2013 9:15 am
by Mark
Hi Simon,

Yes, if you don't want the messages to go up higher in the message hierarchy, then you need mouseUp, mouseDown and mouseDoubleDown handlers, perhaps also mouseMove and other handlers. I'd put them into the image control in this particular case, because the group may not always catch them before the card, if the group has its bgBehavior set to true.

Kind regards,

Mark

Re: No way to prevent clicks on a button

Posted: Mon Jun 24, 2013 6:23 pm
by Mag
Thank you so much friends. Send is a very interesting approach, unfortunately the problem is that I don't know when the AV native control is finished to be created. :(

Re: No way to prevent clicks on a button

Posted: Mon Jun 24, 2013 6:33 pm
by Mark
Hi,

Since in your original solution all mouseUp were collected and fired after the AV control finished, you don't need to know when it finishes. The send command will automatically fire after it finishes. If not, then there was another reason why the mouseUps fired after the AV control finished and you should post your script to let is figure out what you're doing wrong.

Kind regards,

Mark

Re: A way to prevent clicks on a button

Posted: Tue Jun 25, 2013 1:45 pm
by Mag
Mark wrote:

Code: Select all

on hideEverything
  show grp"Black background with progress indicator"
  show btn "Progress Indicator"
  // do the video recording here
  hide btn "Progress Indicator"
  send "showEverything" to me in 100 millisecs
  // 0 millisecs might work too
end hideEverything

on showEverything
  hide grp "Black background with progress indicator"
end showEverything

Hi Mark,

Thank you. Well, it works, and this is great... but it works only for the first tap, if you tap two times, the second tap is fired. To avoid the second tap I need to put "1 second" instead of "100 milliseconds", however, this would delay the time at which the user may use the control.

Here is my code:

Code: Select all

on preOpenCard
   disableButtons
end preOpenCard

on openCard
   createCam
   enableButtons
end openCard

on openCard
   createCam
   send "enableButtons" to this stack in 100 milliseconds
end openCard

on createCam
   try
      mergAVCamCreate
      catch e
      -- answer e
   end try
end createCam

on enableButtons
   hide button "viewCover" of card "main"
end enableButtons

on disableButtons
   show button "viewCover" of card "main"	
end disableButtons

Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 1:51 pm
by Mark
Hi,

You have two openCard handlers. Before I answer, could you please edit your post to make sure that it only contains your actual, working code?

Kind regards,

Mark

Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 1:54 pm
by jmburnod
Hi Mag,

I'm glad you found a way, but I see two opencard handlers in your script.
Best
Jean-Marc

Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 2:04 pm
by Dixie
Have a look at 'flushEvents' in the dictionary...

Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 2:11 pm
by Mark
Dixie,

As I wrote earlier, flushEvents won't work.

Kind regards,

Mark

Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 2:35 pm
by Mag
Oops, sorry! Here is the right code:

Code: Select all

on preOpenCard
   disableButtons
end preOpenCard

on openCard
   createCam
   send "enableButtons" to this stack in 100 milliseconds
end openCard

on createCam
   try
      mergAVCamCreate
      catch e
      -- answer e
   end try
end createCam

on closeCard
   mergAVCamDelete
end closeCard

on enableButtons
   hide button "viewCover" of card "main"
end enableButtons

on disableButtons
   show button "viewCover" of card "main"   
end disableButtons



Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 2:47 pm
by Mark
Hi Mag,

It looks like you are using a card for the AV Cam control. I suspect that this card has no buttons and therefore there is no reason to cover anything. Is that right?

You have a closeCard handler, but I wonder what you're using to leave the card? Do you have a button (or a script in any other control or card or stack) to go back to the previous card? When is this button or script available to the user?

You don't need to have a separate card to use the AV cam control, but you can if you want. So tell me, do you want to use the AV Cam control on a separate card without using the cover or do you want to use it on an arbitrary card with the cover?

Could you please change the createCam handler and tell me when you hear the beep?

Code: Select all

on createCam
   try
      mergAVCamCreate
      catch e
      -- answer e
   end try
   beep
end createCam
Do you hear the beep immediately after the AV Cam control appears or after the control disappears?

Kind regards,

Mark

Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 3:00 pm
by Mag
Hi Mark,

I have three cards, the Main card contains the AV control and a bunch of buttons (start record, go to preview card, settings and so on); then there is the cards Settings and Preview (where you go to see what you have recorded).

In developer environment (OS X) I see immediately the beep. In iOS beep is not reproduced (if I remember correctly iOS don't play beeps).

Re: No way to prevent clicks on a button

Posted: Tue Jun 25, 2013 3:03 pm
by Dixie
iOS can be set to beep !