No way to prevent clicks on a button

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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:10 pm

Dixie wrote:iOS can be set to beep !
Oh, great, I will try right now then.

Edit: OK, I saw this in Dictionary:
Note: The iPhone has no default system alert sound so if a sound is required one must be specified using the beepSound property. The action of beep is controlled by the system and depends on the user's preference settings. In particular a beep will only cause a vibration if the user has enabled that feature. Similarly, a beep will only cause a sound if the phone is not in silent mode.
This I guess means that I I play a sound that I provide the delay will be significant and not as immediate as the beep of a desktop computer... Anyway I will try.
Last edited by Mag on Tue Jun 25, 2013 3:16 pm, edited 1 time in total.

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 3:14 pm

Hi,

It doesn't matter whether you try a beep or an answer dialog or something else you can come up with, as long as you can tell me whether something happens right after executing the mergAVCamCreate control or much later, but I think I'm slowly getting what's going on. Will get back to it later today.

Best,

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:18 pm

Mark wrote:Hi,

It doesn't matter whether you try a beep or an answer dialog or something else you can come up with, as long as you can tell me whether something happens right after executing the mergAVCamCreate control or much later, but I think I'm slowly getting what's going on. Will get back to it later today.

Best,

Mark

Thanks Mark, great, I will try with a put in field command.

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 3:28 pm

Hi,

I think this is what you need:

Code: Select all

on preOpenCard
   // don't do anything, let stack render itself first
   // disableButtons
end preOpenCard

on openCard
   // send createCam message only after LiveCode is ready
   send "createCam" to me in 0 millisecs
   // send "enableButtons" to this stack in 100 milliseconds
end openCard

on createCam
   disableButtons
   put the millisecs into myTimer
   try
      mergAVCamCreate
      catch e
      -- answer e
   end try
   answer (the millisecs - myTimer)
   // sending enableButtons to stack causes execution error
   send "enableButtons" to me in 100 millisecs
end createCam

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

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

// this doesn't seem to be relevant for our problem
on closeCard
   mergAVCamDelete
end closeCard
Let me know the time in the answer dialog that appears and whether the answer dialog appears before or after the AV Cam control is visible.

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:58 pm

At startup about 1127
When returning from another card about 1490

PS
Please note that in an iPod the AV control in this stack takes about 3/4 seconds to create in quality "Standard" (which is the one I use for tests), in quality "High" about 5/6 seconds

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 5:27 pm

Hi,

I expect the script to work now. Let me know.

Best,

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 6:13 pm

Mark wrote:Hi,

I expect the script to work now. Let me know.

Best,

Mark
Hi Mark,

it works! Well, only for a single tap, if you tap more than one time then you'll get that the button under the cover button fires.

If I don't remove the Asnswer statement all works well.

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 6:22 pm

Hi,

What would the user tap on? On the AV Cam control or something else?

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 6:52 pm

I tested more on a button (record button) which starts a timer and then performs the video recording. But this is true for all the buttons present in the card (go to settings, go to preview card and so on), some of them has mouseUp handlers, other have mouseDown handlers. Naturally the effects of the pressing of the button starts as soon as the control is created and the cover button is disappeared.

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 7:06 pm

Hi,

What happens if you send the enableButtons message in 10 seconds? Does the 2nd tap still cause the mouseUp handler in the button to run? Do any other scripts in your project run? Do you have any other scripts that run automatically when the stack or card opens?

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 8:46 pm

Mark wrote:Hi,

What happens if you send the enableButtons message in 10 seconds? Does the 2nd tap still cause the mouseUp handler in the button to run? Do any other scripts in your project run? Do you have any other scripts that run automatically when the stack or card opens?

Kind regards,

Mark
With 4 or more seconds all works and all taps are ignored.

PS
Currently all the other scripts in openCard and preOpenCard are commented.

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 11:35 pm

Hi,

What is happening here is really weird. For now, I'm out of ideas. I think you should report this problem to Monte. Ask him to update the external, e.g. with a callback message that is sent when the external finishes setting up the control.

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 » Thu Jun 27, 2013 3:07 pm

Thank you Mark, and to all other people that post in this topic. I learned a lot with your posts!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: No way to prevent clicks on a button

Post by FourthWorld » Thu Jun 27, 2013 5:30 pm

Have you tried using the flushEvents function to prevent the message from getting into the queue?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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 » Thu Jun 27, 2013 5:48 pm

Richard,

FlushEvents is incompatible with iOS (this thread is in the iOS Deployment forum). This was mentioned two times earlier in this thread.

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

Post Reply