applying scrollbars and losing card position

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

applying scrollbars and losing card position

Post by jalz » Fri Jun 19, 2015 9:20 pm

Hi Guys,

I have the following code below which applies a scrollbar to my card. I call this script from buttons/anytime there is a change of position for an object (I have a lot of objects down the page that are hidden and appear when certain criteria is met). The problem with it is, when I've scrolled a little down, and this script is triggered, the position of contents within my scrollbar get shifted to the top. I know why this is happening, its when I set the top left of group scrollbar to 0,0. I thought I could be clever and get the position of the topleft before i moved it, but that just messes the position of the scrollbar.

Does anyone have any suggestions on how I can prevent the window from losing position, yet retain the scrollbars on my card appropriately?

Many thanks as always
Jalz

Code: Select all

command applyScrollBars
   
   --put the topleft of group "grp_scrollbar" into tCurrentPosition
   put the rectangle of this card into tRect
   set the rectangle of group "grp_scrollbar" to tRect
   set the topleft of group "grp_scrollbar" to 0,0
   
   set the vScrollbar of group "grp_scrollbar" to (the formattedHeight of group "grp_scrollbar" > the height of group "grp_scrollbar")  
   set the hScrollbar of group "grp_scrollbar" to (the formattedWidth of group "grp_scrollbar" > the width of group "grp_scrollbar")
   --set the topleft of group "grp_scrollbar" to tCurrentPosition
   
end applyScrollBars

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: applying scrollbars and losing card position

Post by jalz » Sat Jun 20, 2015 12:49 am

Figured it out using put the scroll of group "grp_scrollbar" into tScrollPosition and then setting the scroll back to this position after the scrollbars have been added.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”