Page 1 of 2

Android Long Click

Posted: Wed Jul 06, 2011 2:49 am
by basheps
Can anyone tell me how to check for a "longclick" in Android? Thanks in advance.

Re: Android Long Click

Posted: Wed Jul 06, 2011 3:36 pm
by Mark
Hi,

Have you tried the mouseStillDown message?

Kind regards,

Mark

Re: Android Long Click

Posted: Sat Jul 09, 2011 7:58 pm
by basheps
Hi Mark,
Have you tried the mouseStillDown message?
From the Dictionary:
"The mouseStillDown message is sent only when the Browse tool is being used. If an unlocked field is clicked with mouse button 1 or 2, no mouseStillDown message is sent."

Re: Android Long Click

Posted: Sat Jul 09, 2011 8:45 pm
by Mark
Hi,

I don't understand your reply.

Mark

Re: Android Long Click

Posted: Sat Jul 09, 2011 9:45 pm
by townsend
Good to know about--

Code: Select all

on mouseStillDown
     beep
end mouseStillDown
Though, this only works for Button objects.

Nothing with Field and DataGrid objects. I was hoping I could change a mouseStillDown on a DataGrid into a double click message, which would be good for Mobil appliations, where double clicks are rare.

Re: Android Long Click

Posted: Sat Jul 09, 2011 9:52 pm
by Mark
OK, I get it...

Maybe you can do something like this:

Code: Select all

on mouseDown
  // make sure to handle any visual stuff here first, if necessary
  wait 300 millisecs with messages
  if the mouse is down then
    // treat like long mouseClick
  else
    // treat like short mouseClick
  end if
end mouseDown
Kind regards,

Mark

Re: Android Long Click

Posted: Sat Jul 09, 2011 10:23 pm
by townsend
How about that? Nice. I had all but given up on this one.

Code: Select all

  on mouseDown
  --make sure to handle any visual stuff here first, if necessary
  wait 300 millisecs with messages
  if the mouse is down then
       --treat like long mouseClick
       beep
       send "mouseDoubleDown" to me
  else
    --treat like short mouseClick
  end if
end mouseDown

on MouseDoubleDown
     answer "Works Good"
end MouseDoubleDown

Re: Android Long Click

Posted: Sun Jul 10, 2011 2:25 pm
by basheps
Makes sense. Thanks so much!

Re: Android Long Click

Posted: Mon Jul 11, 2011 4:51 am
by BarrySumpter
Man!

Where do you guys get this stuff?

Re: Android Long Click

Posted: Wed Aug 03, 2011 1:38 pm
by Mark
25 year experience, Barry :-)

Re: Android Long Click

Posted: Wed Aug 03, 2011 5:06 pm
by jacque
Does the check for the mouse state work? I tried to do that in iOS and it failed every time, I assume because there is no mouse. Does it work in Android?

I'd like to know if it works on a real device, because I have a project that needs it. It would be nice not to have to do a lot of workarounds.

[edit]: By the way, the typical way to detect a long press is to store the milliseconds on touchStart and then compare that with the current milliseconds on touchEnd. If the difference is more than a certain amount, assume a long press.

Re: Android Long Click

Posted: Wed Aug 03, 2011 10:34 pm
by BarrySumpter
Jaque,
Can you please post a working sample?

Re: Android Long Click

Posted: Thu Aug 04, 2011 12:02 am
by Mark
Hi,

Interesting. The mouse() function always returns "up" in Android. I wonder if that's a bug or intended behaviour. I'd say it is a bug, particularly because the mouseStillDown message does seem to work.

MouseStillDown doesn't work in unlocked fields because these fields can't receive mouse event messages! Fields only receive openField, closeField and exitField messages when you click in or outside them (and a few other messages such as selectionChanged, which seem less relevant at this point). This is normal.

In closed fields, buttons and cards, the mouseStillDown message works as expected in Android.

Kind regards,

Mark

Re: Android Long Click

Posted: Thu Aug 04, 2011 12:47 am
by jacque
Mark wrote:Hi,

Interesting. The mouse() function always returns "up" in Android. I wonder if that's a bug or intended behaviour. I'd say it is a bug, particularly because the mouseStillDown message does seem to work.
Yeah, that's what happened in iOS too. It wrecked a lot of code in an old stack I was trying to convert. I don't know if it's a bug or a limitation in the OS, but I can report it.

Barry, the example would be the code segment that Mark suggested.

Re: Android Long Click

Posted: Thu Aug 04, 2011 3:04 am
by BarrySumpter
jacque wrote:Barry, the example would be the code segment that Mark suggested.
Righto.
Thought you were writing about a different procedure.
Thanks for the clarification.