go to next card or previous card

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

go to next card or previous card

Post by prexsoccer » Wed Jun 20, 2012 6:50 am

i have here a problem on detecting if swiping to the left will go to the next card or to the left to the right card.
and swiping down will go to a specific card.

anyone has a sample codes for this? or anyone can please help me.
let me know if you get my point or not.

thank you.
best regards
mike :)

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

Re: go to next card or previous card

Post by Dixie » Wed Jun 20, 2012 8:25 am

Mike...

Are you wanting to do this on a mobile device ?

be well

Dixie

prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

Re: go to next card or previous card

Post by prexsoccer » Wed Jun 20, 2012 12:43 pm

hi dixie,

I want this to work on iPad, I need to know that im sliding down,up,left or right.

thank you for your help.

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

Re: go to next card or previous card

Post by Dixie » Wed Jun 20, 2012 12:58 pm

mike...

I have attached a stack that will help you get started... it allows you to swipe 'left & right'...

be well

Dixie
Attachments
swipes.livecode.zip
(2.02 KiB) Downloaded 220 times

prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

Re: go to next card or previous card

Post by prexsoccer » Wed Jun 20, 2012 1:37 pm

thank you for this stack dixie,
do you have down and up?

I have hard time getting down and up :(

but left and right is not that hard :)

tnx anyways :)

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: go to next card or previous card

Post by sturgis » Wed Jun 20, 2012 2:30 pm

You'll need to differentiate between the 2 swipes. Dixie has shown how to get the offset (absolute value) for horizontal swipe. You'll need to do the same for the vertical movement of the swipe (item 2 of mouseloc designates y position, item 1 is x)

If you compare the 2 values to see which is larger, you'll know if its a left/right vs up/down so you can act accordingly. (You'll of course have to add a vdiff and vdiffoffset local variable) Then just modify your code so that
if abs(hdiff - hdiffoffset) > abs(vdiff - vdiffoffset) then
--code for left right swipe goes here
else
-- code for up/down swipe goes here
end if

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

Re: go to next card or previous card

Post by Dixie » Wed Jun 20, 2012 5:13 pm

Mike...

modified 'swipes' stack... left & right and up & down..

be well

Dixie
Attachments
swipes2.livecode.zip
(2.08 KiB) Downloaded 225 times

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: go to next card or previous card

Post by sturgis » Wed Jun 20, 2012 8:05 pm

Hmm. I can't seem to get it to work. The code is cool. (I can modify it to use mouse events and swipe on the desktop to my hearts content) My kindle just says no! In fact just putting "go next card" in a button isn't working on the kindle fire either.

On the desktop I moved some things around and did the check for which offset is greater (because i'm a clumsy swiper and can get 2 card switches to fire with a single swipe... I'm just that good)

Any clue at all why me and my kindle fire can't make this work? I added a field to each card, then put something into the field right before the go card line to check and make sure I didn't mess up the IF statements. Nope, value is placed in the field, card never changes. (also removed the visual affects stuff just to test) That is when I placed a button with "go next card" in it (all by its lonesome) and still can't get the kf to jump cards.
Dixie wrote:Mike...

modified 'swipes' stack... left & right and up & down..

be well

Dixie

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

Re: go to next card or previous card

Post by Dixie » Wed Jun 20, 2012 8:22 pm

Sturgis...

I'm afraid I can't help you as I only use the iphone simulator and an iphone... the 'swipes' work well both in the sim and on the device.

be well

Dixie

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: go to next card or previous card

Post by sturgis » Wed Jun 20, 2012 8:43 pm

Hmm. Surely there is something i'm doing wrong since I can't get a card switch to occur from a simple button press. Must be nap time! (sleep fixes everything)
Dixie wrote:Sturgis...

I'm afraid I can't help you as I only use the iphone simulator and an iphone... the 'swipes' work well both in the sim and on the device.

be well

Dixie

prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

Re: go to next card or previous card

Post by prexsoccer » Thu Jun 21, 2012 1:31 am

hi dixie,

thank you for this stack, I till try it now. hope this will work :)

thank you very much for the help.

prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

Re: go to next card or previous card

Post by prexsoccer » Thu Jun 21, 2012 3:25 am

I have problem on the stack,

if flips 2 card in one swipe. did i mess something up?

give me a quote please :)

gracias :D

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

Re: go to next card or previous card

Post by Dixie » Thu Jun 21, 2012 12:19 pm

prexsoccer...

There are three cars in the stack... The numbers 1, 2 or 3 are displayed in the middle of the card... however, when you get to the third card (3), you will then be taken to card 1 (1).. so perhaps that is why you say it is 'flipping' two cards...:-)

be well

Dixie

Post Reply