Disable the scroller when scrollGroup is hidden

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Disable the scroller when scrollGroup is hidden

Post by Klaus » Thu Jul 18, 2013 5:41 pm

gpb01 wrote:
Jellicle wrote:Just checked and double-checked - setting the visible of the scroller control deactivates it here :)
+1
Exactly the same here ... :)
Livecode 6.1.0 build 2005 - Commercial Edition
Guglielmo
HA! No comment! 8-)

poliks
Posts: 15
Joined: Mon Jul 01, 2013 8:00 am

Re: Disable the scroller when scrollGroup is hidden

Post by poliks » Tue Jul 23, 2013 10:45 am

OK. please bear with me since i am a newbie. Had to leave this behind for awhile since I had to present a mockup. I used another card instead to display the hidden mode. Lousy of me. Anyways tried it today. Here is my card script.

Code: Select all

global scrollid

on preOpenCard
   
   # default state upon opening
   hide group "scrollGroup"  
   hide grp "ClientOff"
   show btn "ClientOn"
   
   if environment() is not "mobile" then exit preOpenCard
   
   if scrollID is not empty then
      iphoneControlSet scrollid, "visible", true
      exit preOpenCard
   end if
   
   put the rect of fld 1 into fldRect
   put the formattedHeight of fld 1 into fldHeight
   put the width of fld 1 into fldWidth
   set the height of fld 1 to fldHeight
   set the unboundedVScroll of group "scrollGroup"  to true
   iphoneControlCreate "scroller"
   put the result into scrollid
   
   iphoneControlSet scrollid, "rect", fldRect
   iphoneControlSet scrollid, "contentRect", (0, 0, fldWidth, fldHeight)
   iphoneControlSet scrollid, "visible", true
   iphoneControlSet scrollid, "canBounce", true
   iphoneControlSet scrollid, "decelerationRate", slow 
   iphoneControlSet scrollid, "scrollingEnabled", true
   iphoneControlSet scrollid, "canScrollToTop",true
   iphoneControlSet scrollid, "canCancelTouches",true
   iphoneControlSet scrollid, "delayTouches", true
   iphoneControlSet scrollid, "vIndicator", true
   iphoneControlSet scrollid, "indicatorStyle", black
   iphoneControlSet scrollid, "indicatorInsets",  "0,0,0,0"
   iphoneControlSet scrollid, "hscroll", 0
   iphoneControlSet scrollid, "vscroll", 0
   
   
   repeat with count = 1 to the number of lines of fld 1
      set the textShift of line count of fld 1 to - 10
   end repeat
   
   put the vScroll of group "scrollGroup" into fld 3
end preOpenCard

on closeCard
   if environment() is not "mobile" then exit closeCard
   iphoneControlSet scrollid, "visible", false
   set the vscroll of group "ScrollGroup" to 0
   iphoneControlSet scrollId, "vscroll", 0  
end closeCard

on scrollerBeginDrag
   set the hilitedLine of fld 1 to empty
   put empty into fld 2
end scrollerBeginDrag

on scrollerScrollToTop
   iphoneControlSet scrollId, "vscroll", 0   
end scrollerScrollToTop

on scrollerDidScroll hOffset, vOffset
   set the vScroll of group "scrollGroup" to vOffset
   put vOffset into fld 3
end scrollerDidScroll

I have 2 buttons that hides and unhides
I tried it inside the buttons but i get the error

Code: Select all

iphoneControlSet scrollid, "visible", false 
where did you guys place them that will allow me to toggle the Hide and Show states?

Thanks,
Pol

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Disable the scroller when scrollGroup is hidden

Post by Klaus » Tue Jul 23, 2013 11:16 am

Hi Pol,

you need to tell the script that you are using a GLOBAL variable!
A global variable need to be declared in EVERY script you use it!
You already have it correct in your stackscript! :-)

Put this in your "hide/show" buttons:

Code: Select all

##!!!!!
global scrollid

on mouseup
   iphoneControlSet scrollid, "visible", false 
end mouseup
Best

Klaus

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Disable the scroller when scrollGroup is hidden

Post by Jellicle » Tue Jul 23, 2013 12:07 pm

Not just in the buttons - declare the global variable everywhere you make a call to get or set a property of the control.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Disable the scroller when scrollGroup is hidden

Post by Klaus » Tue Jul 23, 2013 12:13 pm

Yes, Gerry :-D

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Disable the scroller when scrollGroup is hidden

Post by Jellicle » Wed Jul 24, 2013 2:09 am

Ooops. Just re-read you post :)

g
14" MacBook Pro
Former LiveCode developer.
Now recovering.

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: Disable the scroller when scrollGroup is hidden

Post by SteveTX » Wed Jul 24, 2013 2:37 am

I don't have this problem on android via LiveCode 6.1. When the native control (not the content/group) is hidden, no scroll bar.

poliks
Posts: 15
Joined: Mon Jul 01, 2013 8:00 am

Re: Disable the scroller when scrollGroup is hidden

Post by poliks » Wed Jul 24, 2013 2:39 am

Hi Guys,

I actually added my global scrollid on the buttons.
Card Script

Code: Select all

global scrollid

on preOpenCard
   
   hide group "scrollGroup"  
   disable group "scrollGroup"
   hide grp "ClientOff"
   show btn "ClientOn"
   
   if environment() is not "mobile" then exit preOpenCard
   
   if scrollID is not empty then
      iphoneControlSet scrollid, "visible", true
      exit preOpenCard
   end if
   
   put the rect of fld 1 into fldRect
   put the formattedHeight of fld 1 into fldHeight
   put the width of fld 1 into fldWidth
   set the height of fld 1 to fldHeight
   set the unboundedVScroll of group "scrollGroup"  to true
   iphoneControlCreate "scroller"
   put the result into scrollid
   
   iphoneControlSet scrollid, "rect", fldRect
   iphoneControlSet scrollid, "contentRect", (0, 0, fldWidth, fldHeight)
   iphoneControlSet scrollid, "visible", true
   iphoneControlSet scrollid, "canBounce", true
   iphoneControlSet scrollid, "decelerationRate", slow 
   iphoneControlSet scrollid, "scrollingEnabled", true
   iphoneControlSet scrollid, "canScrollToTop",true
   iphoneControlSet scrollid, "canCancelTouches",true
   iphoneControlSet scrollid, "delayTouches", true
   iphoneControlSet scrollid, "vIndicator", true
   iphoneControlSet scrollid, "indicatorStyle", black
   iphoneControlSet scrollid, "indicatorInsets",  "0,0,0,0"
   iphoneControlSet scrollid, "hscroll", 0
   iphoneControlSet scrollid, "vscroll", 0
   
   
   repeat with count = 1 to the number of lines of fld 1
      set the textShift of line count of fld 1 to - 10
   end repeat
   
   put the vScroll of group "scrollGroup" into fld 3
end preOpenCard

on closeCard
   if environment() is not "mobile" then exit closeCard
   iphoneControlSet scrollid, "visible", false
   set the vscroll of group "ScrollGroup" to 0
   iphoneControlSet scrollId, "vscroll", 0  
end closeCard

on scrollerBeginDrag
   set the hilitedLine of fld 1 to empty
   put empty into fld 2
end scrollerBeginDrag

on scrollerScrollToTop
   iphoneControlSet scrollId, "vscroll", 0   
end scrollerScrollToTop

on scrollerDidScroll hOffset, vOffset
   set the vScroll of group "scrollGroup" to vOffset
   put vOffset into fld 3
end scrollerDidScroll

Show button. I did place the global variable as well.

Code: Select all

global scrollid

on mouseUp
   iphoneControlSet scrollid, "visible", true
   show grp "ClientOff"
   hide me
   show group "scrollGroup"  with visual effect dissolve very fast
end mouseUp
As well as on my hide button.

Code: Select all

global scrollid

on mouseUp
   iphoneControlSet scrollid, "visible", false
   hide group "scrollGroup"  
   show btn "ClientOn"
   hide me 
end mouseUp
But somewhat I still get an error on the buttons
button "ClientOn": execution error at line 4 (Handler:can't find handler) near "iphoneControlSet", char 1

poliks
Posts: 15
Joined: Mon Jul 01, 2013 8:00 am

Re: Disable the scroller when scrollGroup is hidden

Post by poliks » Wed Jul 24, 2013 2:46 am

Here is actually my LC file.
Attachments
ShowHide.livecode.zip
(4.48 KiB) Downloaded 262 times

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Disable the scroller when scrollGroup is hidden

Post by Klaus » Wed Jul 24, 2013 11:14 am

Hi Pol,

you have the answer in your "preOpenCard" script!:

Code: Select all

on mouseup
 if environment() <> "mobile" then
    exit mouseup
 end if
 ## NOW do your MOBILE thing:
 iphoneControlSet scrollid, "visible", true
...
You need to check this before every MOBILE command!

Best

Klaus

poliks
Posts: 15
Joined: Mon Jul 01, 2013 8:00 am

Re: Disable the scroller when scrollGroup is hidden

Post by poliks » Thu Jul 25, 2013 5:50 am

Awesome!!

It now works flawlessly!

Thank you all!

Post Reply