Swipe up and down Vs Vertical Scroll

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Swipe up and down Vs Vertical Scroll

Post by aebki » Tue Feb 03, 2015 1:08 pm

Hi,

after four or five days blocked with the vertical scroll, i decided to try another thing as i am not seeing the light...:-(
So i decided to use 'swipe up and swipe down' in place of the vertical scroll...
I am already using 'swipe right and swipe left' and it is working well...:-)

But now i am not managing when i am adding the swipe up and down...:-(

i put the sentence "-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE" after all the lines i added to control the swipe up and down...The rest was already working for swipe left and right.

This is the code i have:

Code: Select all

on touchMove pId, pX, pY
   if pId <> sTouchId then
      # record initial values for start of swipe
      put pId into sTouchId
      put the millisecs into sInitTime
      put pX into sInitX
      put pY into sInitY-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
   end if
      
   # check the action was fast enough for a swipe
   if the millisecs - sInitTime <= sSwipeTime then
      # check we have covered enough distance
      put pX - sInitX into tDistanceX
      put pY - sInitY into tDistanceY-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
      if abs(tDistanceX) > sSwipeDistance then
         if tDistanceX < 0 then
            # finger is swiping left
            send "swipeLeft" to me in 0 millisecs
         else
            # finger is swiping right
            send "swipeRight" to me in 0 millisecs
         end if
      else
         if abs(tDistanceY) > sSwipeDistance then-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
            if tDistanceY < 0 then-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
               send "swipeDown" to me in 0 millisecs-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
            else-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
               send "swipeUp" to me in 0 millisecs-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
            end if-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
         end if-- NEW LINE ADDED FOR THE UP AND DOWN SWIPE
      end if
   end if
end touchMove
After this code it is always entering in 'swipe up', even when i am moving to the left or to the right...:-(

What i want is go to card 1 when i swipe up
go to card 2 when i swipe down
go to card 3 when i swipe left
go to card 4 when i swipe right

Is it possible to do what i am trying???If yes, what is the error of my code?

Regads.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Swipe up and down Vs Vertical Scroll

Post by aebki » Tue Feb 03, 2015 2:34 pm

Hi,

I managed to do it!!! :-)

So, it is solved! :-)

Regards

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Swipe up and down Vs Vertical Scroll

Post by keram » Mon Feb 09, 2015 8:40 pm

Great! :)
So what's the solution :?: :?:
keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Swipe up and down Vs Vertical Scroll

Post by aebki » Tue Feb 10, 2015 4:49 pm

Hi Keram,

So when i said it is solved, i was speaking about the fact to make 'swipe up' and 'swipe down'...
So it is not that i found one way to emulate the vertical scroll.
It is only that i could control all the gestures (swipe left, right, up and down)...

Anyway i will let you the code if it is this what you are looking for...:-)

Code: Select all

global horizontalDiff,verticalDiff

on touchStart theID
   put item 1 of mouseLoc() into horizontalDiff
   put item 2 of mouseLoc() into verticalDiff
end touchStart

on touchmove theID
   put item 1 of mouseLoc() into horizontalOffset
   put item 2 of mouseLoc() into verticalOffset
  
   if horizontalDiff > hdiffOffset AND ABS( horizontalDiff - hdiffOffset) > 100  then 
      send "swipeLeft" to me in 0 millisecs
   end if
 
   if horizontalDiff < horizontalOffset AND ABS( horizontalDiff - horizontalOffset) > 100 then 
      send "swipeRight" to me in 0 millisecs
   end if

   if verticalDiff > verticalOffset AND ABS( verticalDiff - verticalOffset) > 100  then 
      send "swipeUp" to me in 0 millisecs
   end if
   
   if vdiff < verticalOffset AND ABS( vdiff - verticalOffset) > 100 then 
      send "swipeDown" to me in 0 millisecs
   end if
   
end touchmove

command swipeLeft
   visual effect scroll left normal
   go to card "TheCardYouWant"
end swipeLeft

command swipeRight
   visual effect scroll right normal
   go to card "TheCardYouWant"
end swipeRight

command swipeUp
   visual effect scroll up normal
   go to card "TheCardYouWant"
end swipeUp

command swipeDown
   visual effect scroll down normal
   go to card "TheCardYouWant"
end swipeDown

Being honest i should tell you that the majority of these things i found them in the forum / lessons...
So, i had only to put in order my ideas ( and the code i already saw )...:-)

I hope it helps you! :-)

Regards.

Klaus
Posts: 11203
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Swipe up and down Vs Vertical Scroll

Post by Klaus » Tue Feb 10, 2015 5:02 pm

Hi folks,

be sure to use the recommended (by RunRev!) syntax:
...
lock screen for visual effect
go cd "TheCardYouWant"
unlock screen with visual effect scroll left normal
...
Unfortunately the docs have not been updated to reflect these changes.


Best

Klaus

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Swipe up and down Vs Vertical Scroll

Post by aebki » Tue Feb 10, 2015 5:47 pm

Hi Klaus,

Thanks for the correction...:-)

I will change it in my code!

I am quite happy doing this solution, even if i would like to use one vertical scroll ones!
So any help or example about how to make this it will be nice from you!
I already tried to understand what was written in the lesson and i didn't manage and also with the advices of Dave i didn't manage...
It is for this i decided to use the swipe up, after many days blocked in the scroll...:-(

What i would really want is to know how to use one vertical scroll when i will have text fields and button in some positions more down that the height of my screen (1024 x 768 ) or more than the height of the group of all these buttons and fields.
It is like if i have 10 fields shown in the screen and 10 more hidden ( as they are down ) and i will need to scroll to see these values.
I hope i expressed well myself! :-)

Regards

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Swipe up and down Vs Vertical Scroll

Post by keram » Wed Feb 11, 2015 3:23 am

Hi,
Klaus wrote:be sure to use the recommended (by RunRev!) syntax:
Yes, but it not always works properly, it's buggy in some cases - see my bug report here:
http://quality.runrev.com/show_bug.cgi?id=12641
Read my post from 2014-12-25 at the bottom.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Swipe up and down Vs Vertical Scroll

Post by keram » Thu Feb 12, 2015 12:19 am

Hi aebki,
aebki wrote:I already tried to understand what was written in the lesson
Is it this lesson that you are referring to? http://lessons.runrev.com/s/lessons/m/4 ... ll-a-field

You may also try to create the scroller with MobGUI: http://mobgui.com/index.php - that's maybe easier for you.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Swipe up and down Vs Vertical Scroll

Post by aebki » Thu Feb 12, 2015 10:41 am

Hi Keram,

Thanks for your advice...:-)

In fact i was looking at these two lessons:

http://lessons.runrev.com/m/4071/l/4442 ... chitecture

and

http://lessons.runrev.com/m/4071/l/1178 ... the-window

Regards.

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Swipe up and down Vs Vertical Scroll

Post by keram » Thu Feb 12, 2015 5:08 pm

Hi aebki,

I modified the code from this lesson http://lessons.runrev.com/m/4071/l/1178 ... the-window so that scrolling is continuous and smooth when you hold the mouse on the arrows. So the code for the arrow UP is:

Code: Select all

on mouseDown
   repeat while the mouse is down
      put the loc of group "map display" into theLoc
      set the loc of of group "map display" to (item 1 of theLoc, item 2 of theLoc - 1)
   end repeat
end mouseDown
and for the remaining arrows see the attached stack.

From reading your description about what you want to accomplish it looks to me that you need to create a scroller for a group consisting of many fields, so the lesson from second link may not be what you really need.

keram
Attachments
Map_Viewer2.zip
(233.15 KiB) Downloaded 54 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Swipe up and down Vs Vertical Scroll

Post by aebki » Thu Feb 12, 2015 7:33 pm

Hi Keram,

Thanks for your example...:-)

Regards.

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

Re: Swipe up and down Vs Vertical Scroll

Post by Dixie » Tue Feb 17, 2015 1:41 am

I have attached a stack that goes another way about moving a large 'map' (read image) inside a stack window that is smaller than the image... All the handlers are in the card script... It is a map of the London underground, without the colour sothat it could be posted on th forum...

Hold the mouse down and drag to scroll the map, you can also resize the stack window...

hope it helps...:-)
Attachments
movemap.livecode.zip
(213.69 KiB) Downloaded 66 times

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: Swipe up and down Vs Vertical Scroll

Post by aebki » Tue Feb 17, 2015 10:02 am

Hi Dixie,

Thanks for your example...:-)

Regards.

Post Reply

Return to “iOS Deployment”