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: FourthWorld, heatherlaine, Klaus, kevinmiller
-
jalz
- Livecode Opensource Backer
- Posts: 340
- Joined: Fri Sep 12, 2008 11:04 pm
Post
by jalz » Tue Sep 29, 2015 11:57 pm
Hey guys, Im using the resizeStack handler to apply scrollbars to my page layout of they are needed. The actual code for the page works great when the window of the page is resized by the user. I also call that handler on a navigation button which got to the next card and adds a scrollbar if required. The problem I have is, when I call the handler on one of my navigation buttons, the screen seems to flicker when applying the scrollbar, and if its it the first time you're on a particular card, you see the scrollbar move to the width of the card. I've read that lock screen should be able to stop objects being drawn, but I can't seem to get it to work for me. Can someone point me in the right direction please.
Thanks
Jalz
Code: Select all
on resizeStack newWidth,newHeight,oldWidth,oldHeight
put the short name of this cd into tCardName
put "Grp_" & tCardName into tGroupName
lock screen
if newHeight is not empty then
set the height of group tGroupName to newHeight
else
set the height of group tGroupName to the height of this card
end if
if newWidth is not empty then
set the width of group tGroupName to newWidth
else
set the width of group tGroupName to the width of this card
end if
set the topleft of group tGroupName to 0,0
if exists(group tGroupName) then
set the vScrollbar of group tGroupName to (the formattedHeight of group tGroupName > the height of group tGroupName )
set the hScrollbar of group tGroupName to (the formattedWidth of group tGroupName > the width of group tGroupName )unlock screen
end if
unlock screen
end resizeStack
-
dunbarx
- VIP Livecode Opensource Backer
- Posts: 9579
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Post
by dunbarx » Wed Sep 30, 2015 2:44 am
Hi.
Is it possible other handlers are executing after the "reSizeStack" message is sent, and stuff there changes the look of things? A long shot, but what happens if you do NOT unlock the screen at the end of that handler?
You do not have to, you know, since the LockScreen property automatically defaults to "false" when all handlers end.
Craig Newman
-
FourthWorld
- VIP Livecode Opensource Backer
- Posts: 9802
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
-
Contact:
Post
by FourthWorld » Wed Sep 30, 2015 3:13 am
First, take the lockScreen and unlock screen statements out; they shouldn't be needed in a resizeStack handler, and I've seen them cause confusion in that context.
Also, consider setting the lockLoc of the group to true, along with the objects within the group. Many anomalies with group resizing are easily solved by reducing this way, bypassing the default auto-resize behavior of groups which attempt to adjust themselves to fit their content while their content is moving around.
Let us know how those work out, and if you still can't get it working we can explore other options.
-
Klaus
- Posts: 13806
- Joined: Sat Apr 08, 2006 8:41 am
- Location: Germany
-
Contact:
Post
by Klaus » Wed Sep 30, 2015 12:37 pm
And cleaning up the script a bit wouldn't hurt either
Code: Select all
on resizeStack newWidth,newHeight,oldWidth,oldHeight
put the short name of this cd into tCardName
put "Grp_" & tCardName into tGroupName
## The parameters are NEVER empty!
# if newHeight is not empty then
# set the height of group tGroupName to newHeight
# else
# ...
# end if
# set the topleft of group tGroupName to 0,0
## This is faster and cleaner:
set the rect of grp tGroupName to the rect of this cd
## Of course the group existst, or you would have seen lots of error from the first line on!
## if exists(group tGroupName) then
set the vScrollbar of group tGroupName to (the formattedHeight of group tGroupName > the height of group tGroupName )
set the hScrollbar of group tGroupName to (the formattedWidth of group tGroupName > the width of group tGroupName )
end resizeStack
Best
Klaus
-
jalz
- Livecode Opensource Backer
- Posts: 340
- Joined: Fri Sep 12, 2008 11:04 pm
Post
by jalz » Wed Sep 30, 2015 11:41 pm
Hey all,
Thank you all for your input, I've removed the lock screen command from the resizeStack and added the command when I call resizeStack on the buttons (left/right) but still encountering scrollbar to jump from the last position to the edge of the card.
I've also locked the group on the page and I've even cleaned up the code thanks to Klaus - its a lot leaner and faster.
The problem still persists, I've created a basic sample stack to show you what my app is doing, do you see the scroll bar 'move' when resizing the page and then clicking on the left right buttons on the top of the page to navigate around.
Anyone have a look and help me to fix the scrollbars so they don't move when flipping form one card to the other.
Thanks as always
Jalz
-
Attachments
-
- stack.livecode.zip
- (2.41 KiB) Downloaded 153 times
-
jalz
- Livecode Opensource Backer
- Posts: 340
- Joined: Fri Sep 12, 2008 11:04 pm
Post
by jalz » Thu Oct 01, 2015 8:25 pm
All sorted now
-
FourthWorld
- VIP Livecode Opensource Backer
- Posts: 9802
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
-
Contact:
Post
by FourthWorld » Thu Oct 01, 2015 10:30 pm
jalz wrote:All sorted now
What changed?
-
jalz
- Livecode Opensource Backer
- Posts: 340
- Joined: Fri Sep 12, 2008 11:04 pm
Post
by jalz » Thu Oct 01, 2015 11:01 pm
I basically rearranged, where I put the lock screen. I wrapped it around the entire bit of code which goes to next card, resize stack etc etc and it seems to be stable. When I just had lock screen wrapped around the resizeStack command, like my example stack it didn't work. Amazing what a little bit of rearranging can do.
Code: Select all
on mouseUp
if field "fld_page_no" = 1 then
exit to top
else
lock screen
go to the previous card
resizeStack
put the short name of this cd of stack gStackName into tCardName
set itemdelimiter to space
put item 2 of tCardName into field "fld_page_no"
unlock screen
end if
end mouseUp