Page 1 of 2

help me

Posted: Wed Jun 17, 2015 6:53 pm
by sunkim
hi everyone
I don"t know why
following script is work well on pc
but not work on the android phone

'repeat until the mouseClick'
or
'repeat until the mouseClick is true'

I have tested this script for many days
and I knew
"the mouseClick" function is not work on android
I think this problem may be error of Livecode
right?

anyone help me
warm regard

Re: help me

Posted: Wed Jun 17, 2015 7:53 pm
by dave.kilroy
hi sunkim - actually the dictionary says the mouseClick as also available on Android...

Re: help me

Posted: Wed Jun 17, 2015 9:50 pm
by sunkim
hi dave
would you give me a sample script?

I did some sample script in dictionary
but did not work on android

Re: help me

Posted: Wed Jun 17, 2015 9:54 pm
by dave.kilroy
hi sunkim - no, I think the best thing would be for you to post your script so we can see what you are trying to do and where any bugs might lurk that you've missed...

dave

Re: help me

Posted: Wed Jun 17, 2015 9:58 pm
by sunkim
hi dave
it doesn't work very simple script like this

on mouseup
repeat until the mouseClick
beep
end repeat
end mouseup

what's wrong?
thank's your answer
sunkim

Re: help me

Posted: Wed Jun 17, 2015 10:08 pm
by SparkOut
If this is not a bug, then certainly it's a documentation error.
By default, errors on Android fail silently without explanatory messages. Using the mouseClick syntax never triggers the repeat loop. I therefore believe the mouseClick is not supported on Android, despite what the Dictionary says. I can sort of see why, since there is no mouse, but the mouse messages have been ported to the mobile platforms, so maybe this function has been overlooked.

Anyway, you can work around this issue by updating the card script to:

Code: Select all

on openCard
   set the cRunning of this card to true
   repeat until the cRunning of this card is false
      nextword
      wait for 100 milliseconds with messages
      --include "with messages" to make sure the engine has a chance to poll 
      --for interactive events without the repeat loop taking over all cycles
   end repeat
end openCard

on touchStart
   set the cRunning of this card to false
end touchStart

Re: help me

Posted: Wed Jun 17, 2015 10:09 pm
by dave.kilroy
hi sunkim - could you post some code that is actually from your stackfile - it makes a difference if you send actual code rather than pseudo code - if you send actual code we can see where bugs may be hiding - if you send pseudo code then we can't help (it's a bit like going to the doctor with a pseudo 'bad leg' - the doctor needs to see your actual, real 'bad leg')

So, why not zip up your stackfile and post it here?

Kind regards

Dave

Re: help me

Posted: Wed Jun 17, 2015 10:13 pm
by dave.kilroy
well done sparkout - you were more helpful and more giving than me!

Re: help me

Posted: Wed Jun 17, 2015 10:17 pm
by sunkim
hi dave

I'll try your code
and thanks lot your advice

sunkim

Re: help me

Posted: Wed Jun 17, 2015 10:19 pm
by dave.kilroy
sunkim - it was sparkout and not me who posted code for you...

Re: help me

Posted: Wed Jun 17, 2015 10:31 pm
by sunkim
hi sparkout
thanks lot
I'll try your code

sunkim

:mrgreen: my english is short

Re: help me

Posted: Thu Jun 18, 2015 12:53 am
by Simon
I'm thinking the actual issue may have been the "beep" and a repeat loop with no delay.

Simon

Re: help me

Posted: Thu Jun 18, 2015 7:17 am
by SparkOut
I didn't use beep but I did try it out, using the code structure sunkim requested help with in the original post on the same lines. The mouseClick definitely fails on Android. The repeat loop never even triggers.

Re: help me[solved]

Posted: Thu Jun 18, 2015 5:50 pm
by sunkim
hi SparkOut
thank you very much
your code worked well
my problem have solved by you
again thanks lot
thank everyone
:D

sunkim

Re: help me

Posted: Thu Jun 18, 2015 7:20 pm
by jacque
SparkOut's method is the recommended way to handle mouse events inside a repeat loop. I think "mouseclick" is supported on Android but isn't reliable inside a loop. I just did a quick Android test with this handler:

Code: Select all

on mouseUp
  repeat until the mouseclick
    put the seconds into fld 1
    wait 1 with messages
  end repeat
end mouseUp
The repeat loop does run for me and the seconds are updated as expected. But a tap does not exit the repeat, no matter where I tap on screen. If I had used "beep" instead of the seconds like the OP, expecially without any wait time, the overhead for the audio to load would take longer than the time for the next iteration of the loop, so I suspect that's why no beeps were heard.

Repeat loops shouldn't use the mouseclick as an exit test even on desktop apps because of the way LC tests for a click. If the click is not completed at the exact moment the test occurs, it will be missed. If you click while the interior of the loop is running, it won't always be recognized. On desktops it seems to be a little more reliable, maybe because those machines are faster, but it will still miss some clicks occasionally if the timing isn't exactly right.

There is more info here about testing for various mouse conditions: http://www.hyperactivesw.com/polling.html The example uses a mouseMove handler to explain, but a repeat loop should use the same method, just as SparkOut's solution does.