LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
paulsr
- Posts: 222
- Joined: Thu Jul 19, 2012 9:47 am
-
Contact:
Post
by paulsr » Sat Jun 15, 2013 9:38 am
Folks, would appreciate help with the flwg:
I have a card which has buttons on it. But I also want to be able to swipe left/right on the card to be able to switch to other cards.
So, I overlayed the card and its buttons with one full card-sized button called BtnSwipe. I added the flwg code to BtnSwipe...
Code: Select all
local sStartH
on mouseDown
put the mouseH into sStartH
end mouseDown
on mouseUp
put abs(the mouseH - sStartH) into t_diff
if abs(the mouseH - sStartH) > 50 then
if the mouseH < sStartH then
answer "go right"
else
answer "go left"
end if
else
pass mouseUp
end if
end mouseUp
The tests "go right" "go left" work fine, but if I tap on one of the underlying buttons, nothing happens. I thought the "pass mouseUp" statement would cause the mouseUp message to be passed to the next level.
Plz can someone enlighten me. Tkx...
--paul
-
Simon
- VIP Livecode Opensource Backer

- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
Post
by Simon » Sat Jun 15, 2013 9:59 am
Hi Paul,
Check out this:
http://lessons.runrev.com/s/lessons/m/4 ... r-the-ipad
It uses touchStart, touchMove for swipes, it's down the page a bit. It also has buttons on it so it's much like yours. I see that you'll have to code "moveBack".
Aside from that the "pass mouseUp" is stopped in it's path after it was acted upon:
http://lessons.runrev.com/s/lessons/m/4 ... ssage-path
You could use "send" based on the "mouseLoc" to the button in your code, but that seems very convoluted.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
Dixie
- Livecode Opensource Backer

- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
Post
by Dixie » Sat Jun 15, 2013 10:36 am
Paul..
I'm assuming that this is for mobile ?... attached a stack that allows you to 'swipe'...you would also be able to place buttons on the card that would accomplish the same thing... the 'swipe' only occurs if the 'swipe' covers a distance of 100 pixels... this can be changed to suit your needs...
-
Attachments
-
- swipes.livecode.zip
- (2.11 KiB) Downloaded 239 times
-
paulsr
- Posts: 222
- Joined: Thu Jul 19, 2012 9:47 am
-
Contact:
Post
by paulsr » Sat Jun 15, 2013 10:38 am
Thanks Simon, I'm looking at that now. I tried something similar, by placing the swipe detection code on the card, but that only works if the position of the swipe start is not one of the buttons on the card. I see this example puts the swipe detection into the stack script, but as coded, I can't do that because I have other cards in the stack where the swipe detection is not needed.
Yeah, I looked at that example, and played around with adding buttons, but I get couldn't those buttons to "see" the mouseUp either. Your last suggestion might be the best solution, even tho convoluted.
Altho, I don't understand your statement: 'the "pass mouseUp" is stopped in it's path after it was acted upon'? By ignoring the swipe and passing the mouseUp, has it been acted upon. Confused.
--paul
-
Simon
- VIP Livecode Opensource Backer

- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
Post
by Simon » Sat Jun 15, 2013 6:35 pm
Hi Paul.
By ignoring the swipe and passing the mouseUp, has it been acted upon
Sorry my error.
Looking at the message path image (in the above lesson) pass mouseUp goes from the control to the card not to a control next to your big button.
I can't do that because I have other cards in the stack where the swipe detection is not needed
Can't that be handled by:
if this cd is not in mySwipeCards then exit
something like that, where you put all the swipeable cd's into a var or the otherway around (whichever list is shorter)?
Really mouseLoc isn't the way to go, it was just in case there was something you were leaving out. There are plenty of examples of swipes and buttons.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
paulsr
- Posts: 222
- Joined: Thu Jul 19, 2012 9:47 am
-
Contact:
Post
by paulsr » Sun Jun 16, 2013 7:22 am
Thanks Guys, I've solved it now.
Simply by checking touchStart/End rather than mouseDown/Up on the card, the problem went away. I didn't need to 'pass touchStart' etc. from the buttons. The card seems to "see" the touches, even if they are on a button.
Yes, the app is destined for iOS, so that change does not create a problem, but I was hoping to make it run on my Windoze box, just for testing. No big deal.
I was actually quite close. By putting 'pass mouseDown" (& mouseUp) onto the buttons, I was able to swipe on a button, and the button would ignore the swipe and pass the mouseDown/Up to the card. But it wouldn't work if the mouseDown/swipe started on one button and the mouseUp/swipe ended on another button. I can't think why, but the card didn't "see" the mouseUp.
So, thanks again ... on to the next problem ...
--paul