No way to prevent clicks on a button

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: No way to prevent clicks on a button

Post by Simon » Mon Jun 24, 2013 6:54 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

A way to prevent clicks on a button

Post by Mark » Mon Jun 24, 2013 8:41 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: No way to prevent clicks on a button

Post by Simon » Mon Jun 24, 2013 8:58 am

How about an:
on mouseUp
--do nothing
end mouseUp
in the Black grp/image script?
Would that capture the clicks and dismiss them?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: No way to prevent clicks on a button

Post by Mark » Mon Jun 24, 2013 9:15 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: No way to prevent clicks on a button

Post by Mag » Mon Jun 24, 2013 6:23 pm

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. :(

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: No way to prevent clicks on a button

Post by Mark » Mon Jun 24, 2013 6:33 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: A way to prevent clicks on a button

Post by Mag » Tue Jun 25, 2013 1:45 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: No way to prevent clicks on a button

Post by Mark » Tue Jun 25, 2013 1:51 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: No way to prevent clicks on a button

Post by jmburnod » Tue Jun 25, 2013 1:54 pm

Hi Mag,

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

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: No way to prevent clicks on a button

Post by Dixie » Tue Jun 25, 2013 2:04 pm

Have a look at 'flushEvents' in the dictionary...

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: No way to prevent clicks on a button

Post by Mark » Tue Jun 25, 2013 2:11 pm

Dixie,

As I wrote earlier, flushEvents won't work.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: No way to prevent clicks on a button

Post by Mag » Tue Jun 25, 2013 2:35 pm

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



Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: No way to prevent clicks on a button

Post by Mark » Tue Jun 25, 2013 2:47 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: No way to prevent clicks on a button

Post by Mag » Tue Jun 25, 2013 3:00 pm

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).

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: No way to prevent clicks on a button

Post by Dixie » Tue Jun 25, 2013 3:03 pm

iOS can be set to beep !

Post Reply