Android Long Click

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

basheps
Posts: 11
Joined: Tue May 31, 2011 11:53 am

Android Long Click

Post by basheps »

Can anyone tell me how to check for a "longclick" in Android? Thanks in advance.
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android Long Click

Post by Mark »

Hi,

Have you tried the mouseStillDown message?

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
basheps
Posts: 11
Joined: Tue May 31, 2011 11:53 am

Re: Android Long Click

Post 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."
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android Long Click

Post by Mark »

Hi,

I don't understand your reply.

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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Android Long Click

Post 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.
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android Long Click

Post 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
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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Android Long Click

Post 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
basheps
Posts: 11
Joined: Tue May 31, 2011 11:53 am

Re: Android Long Click

Post by basheps »

Makes sense. Thanks so much!
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Android Long Click

Post by BarrySumpter »

Man!

Where do you guys get this stuff?
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android Long Click

Post by Mark »

25 year experience, Barry :-)
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
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android Long Click

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Android Long Click

Post by BarrySumpter »

Jaque,
Can you please post a working sample?
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android Long Click

Post 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
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
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android Long Click

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Android Long Click

Post 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.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Post Reply