PagingEnabled Horizontally

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Jarren
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 21
Joined: Sat Jan 19, 2013 3:31 am

PagingEnabled Horizontally

Post by Jarren » Tue Apr 23, 2013 8:43 pm

Is there a way to only have the iPhoneControl "PagingEnabled" to work horizontally? I have a datagrid in a native scrolling group, and I'd like to have a couple of columns off to the side, accessible by swiping. I'd like to be able to swipe up and down just normally, but use the paging feature when I swiped horizontally.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: PagingEnabled Horizontally

Post by Simon » Tue Apr 23, 2013 10:24 pm

I think you are going to have to use 2 cards with duplicate datagrids, the first card has the left side of the datagrid showing and card 2 the dg should have it's location set so that it only shows the columns you want.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jarren
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 21
Joined: Sat Jan 19, 2013 3:31 am

Re: PagingEnabled Horizontally

Post by Jarren » Tue Apr 23, 2013 10:26 pm

Hmm... Alright, thanks for the suggestion. I'll see if I can get it to work.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: PagingEnabled Horizontally

Post by Simon » Tue Apr 23, 2013 10:36 pm

Ahh shoot!
I just realised it gets a bit more complicated. If you are halfway down the page and swipe to the next card you have to scroll down to where you were. This can be coded for but it's a bit more effort.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jarren
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 21
Joined: Sat Jan 19, 2013 3:31 am

Re: PagingEnabled Horizontally

Post by Jarren » Tue Apr 23, 2013 11:50 pm

Thats always been something I've tried to figure out to no avail.... How do you save your scroll location and pick it up again?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: PagingEnabled Horizontally

Post by Simon » Tue Apr 23, 2013 11:55 pm

Check out vScroll in the dictionary
You should set the vSroll of the field/group in card 2 on preOpen

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jarren
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 21
Joined: Sat Jan 19, 2013 3:31 am

Re: PagingEnabled Horizontally

Post by Jarren » Wed Apr 24, 2013 12:35 am

Aha! Got everything working properly, thank you for the help!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: PagingEnabled Horizontally

Post by Simon » Wed Apr 24, 2013 1:07 am

Glad I could help! :D

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jarren
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 21
Joined: Sat Jan 19, 2013 3:31 am

Re: PagingEnabled Horizontally

Post by Jarren » Wed Apr 24, 2013 1:47 am

I guess I'm still having a minor issue. Sorry for taking the original question completely off topic. But since we were talking about resuming the location of the scroller, I've got a little problem. The scroller resumes to its correct location, after a split second of it being in its start location. Here's the code, if you could look at it that would be great.

Code: Select all

local sScrollerID
local sScroll

on preOpenCard
   send createscroller to me
end preOpenCard

on createscroller
   lock screen
   if the environment is not "mobile" then
      exit createscroller
      unlock screen
   end if
   set the vScroll of group "ScrollerGroup" to 0   
   iphoneControlCreate "scroller"
   put the result into sScrollerId
   set the unboundedVScroll of group "Scrollergroup" to true 
   iphoneControlSet sScrollerId, "vScroll", sScroll
   iphoneControlSet sScrollerId, "visible", "true"
   iphoneControlSet sScrollerId, "canBounce", "true"
   iphoneControlSet sScrollerId, "ScrollingEnabled", "true"
   iphoneControlSet sScrollerId, "pagingEnabled", "false"
   iphoneControlSet sScrollerId, "canScrollToTop", "true"
   iphoneControlSet sScrollerId, "vIndicator", "false"
   iphoneControlSet sScrollerId, "contentRect",  (0,0,320,800)
   iphoneControlSet sScrollerId, "rect", (the rect of group "ScrollerGroup")
   unlock screen
end createscroller


on scrollerDidScroll OffsetX, OffsetY
[b]   set the vScroll of group "ScrollerGroup" to OffsetY
[/b]end scrollerDidScroll

on closecard 
   if the environment is not "mobile" then
      exit closecard
   end if
[b]   put the vScroll of group "ScrollerGroup" into sScroll
[/b]   iphoneControlDelete sScrollerId
end closecard

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: PagingEnabled Horizontally

Post by Simon » Wed Apr 24, 2013 2:50 am

To get you started try removing from the closeCard
iphoneControlDelete sScrollerId
and adding to the top
global sScrollerId,sScrollerIdcd2

Code: Select all

on preOpenCard
if sScrollerId = empty then
   createscroller
end if
end preOpenCard
(note that you don't have to have the send command for a handler)
Do that for both cards with sScrollerIdcd2 on the second card with all the create related to that.

Put the iphoneControlDelete sScrollerId (and sScrollerIdcd2) in a on closeStack handler.

I "think" that should speed up moving from card to card but the 1st time you use it there will be a delay. I don't see a way to create a control on a different card.

Also try setting the vScroll of cd 2 at the same time as 1

Code: Select all

on scrollerDidScroll OffsetX, OffsetY
  set the vScroll of group "ScrollerGroup" to OffsetY
  if sScrollerIdcd2 <> empty then
     set the vScroll of group "ScrollerGroupcd2" of cd2 to OffsetY
   end if
end scrollerDidScroll
remove any preOpenCard vScroll settings.

Ok that is a crazy start, there is probably a lockscreen method on preOpenStack to create both scrollers.
This is all untested.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jarren
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 21
Joined: Sat Jan 19, 2013 3:31 am

Re: PagingEnabled Horizontally

Post by Jarren » Wed Apr 24, 2013 9:19 pm

Thanks for all the help Simon! I think I have decided to go a slightly different route with regards to the two datagrids, but your advice has been helpful for other aspects of my app!

Thanks again!

Jarren

Post Reply