Page 1 of 1
Lockloc groups and changing rotation
Posted: Sat Oct 29, 2016 8:58 pm
by cusingerBUSCw5N
I have grouped some buttons that are supposed to be 80% of the width of the device.
In resizestack, I have this code:
Code: Select all
on resizeStack
if the environment is "mobile" then
mobileControlDelete "adminScroller"
end if
set the locklocation of group "group biz" to false
layoutControls
set the locklocation of group "group biz" to true
if the environment is "mobile" then
createScroller
end if
end resizeStack
so it turns off the locklocation, then sets the new layout, and then locks it again.
When the mobile device is rotated in ANDROID - it works fine. When it is rotated on IOS - the buttons in the group keep the same width - the scrolling fails, and everything else locks up. I have tested every part of this script to see if it failed at some point - but it processes the whole page- - but has no changes to the sizing, a broken scroller, and no ability to push any buttons - in IOS.
Layout controls clearly says to set the width of the buttons to 80% - and when I put an answer tag - it says that it's done it... but visually it is still the same.
I have also tried adding this at the end of layoutcontrols:
Code: Select all
set the width of group "group biz" to the formattedwidth of group "group biz"
set the left of group "group biz" to tstackwidth*.10
but that doesn't change anything.
I have also tested to make sure locklocation of that group is false when it is in layoutcontrols, and have confirmed that it is false.
So what did I do wrong?
Re: Lockloc groups and changing rotation
Posted: Mon Oct 31, 2016 9:10 pm
by cusingerBUSCw5N
Nobody likes my question... Probably because it has an answer that is obvious to everyone but me. I have attached the stack to see if anyone else gets the results I get - which is that it doesn't rotate properly to landscape.
Re: Lockloc groups and changing rotation
Posted: Mon Oct 31, 2016 9:29 pm
by dunbarx
I love your question.
But I do not develop for mobil.
Craig
Re: Lockloc groups and changing rotation
Posted: Mon Oct 31, 2016 10:18 pm
by SparkOut
I love your question, but I don't develop for ios
Re: Lockloc groups and changing rotation
Posted: Mon Oct 31, 2016 10:51 pm
by dunbarx
Sparkout is always more finely focussed than I am.
Anyway, sorry for this nonsense, cusingerBUSCw5N, but certainly someone will actually help you shortly.
Craig
Re: Lockloc groups and changing rotation
Posted: Mon Oct 31, 2016 11:31 pm
by SparkOut
Yes, apologies for the nonsense, but I meant to imply that some nearer approach to the answer you need will come, hopefully sooner rather than later
Re: Lockloc groups and changing rotation
Posted: Tue Nov 01, 2016 4:09 pm
by jacque
It sounds like the resizing worked but the screen isn't redrawn correctly. If you are sure there are no unpaired lockscreen commands, I'd report it as a bug.
Are you using a fullscreenmode? If so, I wonder if your scripted resizing is interfering with the engine's automatic ones.
Re: Lockloc groups and changing rotation
Posted: Tue Nov 01, 2016 8:44 pm
by cusingerBUSCw5N
I received code from Dave Kilroy that actually works. But I have not idea why it works. It seems counter intuitive.
On the card script, he added some variables for iPhone
Code: Select all
on preopencard
resizeStack
end preopencard
on resizestack
dispatch "autopositionMe" to grp "mygroup"
if isMobile() then createScroller
end resizestack
on createScroller
if "adminScroller" is among the lines of mobileControls() then mobileControlDelete "adminScroller"
--
put the rect of grp "mygroup" into tScrollerRect
put the formattedrect of grp "mygroup" into tContentRect
set the unboundedVScroll of grp "mygroup" to true
--
mobileControlCreate "scroller", "adminScroller"
put the result into tScrollID
--
mobileControlSet tScrollID, "rect", tScrollerRect
mobileControlSet tScrollID, "contentRect", tContentRect
mobileControlSet tScrollID, "visible", "true"
mobileControlSet tScrollID, "vIndicator", "true"
mobileControlSet tScrollID, "vscroll", 0
mobileControlSet tScrollID, "hscroll", 0
if platform() = "iphone" then
mobileControlSet tScrollID, "canBounce", "true"
mobileControlSet tScrollID, "canScrollToTop", "true"
mobileControlSet tScrollID, "canCancelTouches", "true"
mobileControlSet tScrollID, "delayTouches", "true"
mobileControlSet tScrollID, "pagingEnabled", "false"
mobileControlSet tScrollID, "decelerationRate", "fast"
mobileControlSet tScrollID, "indicatorStyle", "black"
mobileControlSet tScrollID, "scrollingEnabled", "true"
mobileControlSet tScrollID, "lockDirection", "true"
end if
end createScroller
on scrollerDidScroll hOffset, vOffset
set the vscroll of group "mygroup" to vOffset
set the hscroll of group "mygroup" to 0
end scrollerDidScroll
on closecard
if isMobile() then
if "adminScroller" is among the lines of mobileControls() then mobileControlDelete "adminScroller"
end if
end closecard
but those variables weren't enough to fix the problem. He also moved the positioning from the card script and resize into the script for the group. This is where my confusion comes. He LOCKS the group and then resizes it..... I thought you UNLOCKED the group, resized it and then LOCKED it again.
Code: Select all
on autoPositionMe
set the lockLoc of me to true
put the width of this stack into tStackWidth
put the height of this stack into tStackHeight
put max((tStackHeight * 0.02),20) into tVerticalSpace
put the loc of the current card into tLoc
put tStackWidth * 0.80 into tButtonWidth
put tStackWidth * 0.10 into tButtonLeft
put 10 into tButtonPadding
--
set the top of button "return" to 170
set the left of button "return" to (tStackWidth * 0.05)
--
repeat with i = 1 to 10
set the width of btn ("button" & i) to tButtonWidth
set the loc of btn ("button" & i) to tLoc
if i = 1 then put (the bottom of btn "return" + tVerticalSpace) into tButtonTop
else put (the bottom of btn ("button" & (i - 1)) + tVerticalSpace) into tButtonTop
set the top of btn ("button" & i) to tButtonTop
put the bottom of btn ("button" & i) into tButtonBottom
end repeat
--
set the rect of grc "grcBase" of me to ((the left of btn "button1") - tButtonPadding), \
((the top of btn "button1") - tButtonPadding), \
((the right of btn "button1") + tButtonPadding), \
(tButtonBottom + tButtonPadding)
--
set the rect of me to ((the left of btn "button1") - tButtonPadding), \
((the top of btn "button1") - tButtonPadding), \
((the right of btn "button1") + tButtonPadding), \
(tStackHeight - tButtonPadding)
--
set the vscroll of me to 0
end autoPositionMe
This is in the stack script
Code: Select all
on preopenstack
if isMobile() then
--answer "mobile"
put "portrait,portrait upside down,landscape left,landscape right" into theallowed
-- Function Call
mobileSetAllowedOrientations theallowed
end if
end preopenstack
function isMobile
return the environment is "mobile"
end isMobile
So can anyone explain lockloc - and why this version works in IOS...and the my version doesn't(in IOS)? I'd ask Dave...but he's traveling for a few days...and I am just confused.
Re: Lockloc groups and changing rotation
Posted: Wed Nov 02, 2016 9:34 pm
by jacque
The lockLoc property only applies to manual changes when dragging with the mouse. Controls can be resized by script regardless of that setting. The other thing to know is that a group will automatically resize to fit its contents unless lockLoc is true. A group with lockLoc set to true will not change dimensions, just as an image with lockLoc true will not resize itself when the card redraws.
I assume Dave's script locks the group so that the control resizing won't cause the group to resize. That still doesn't explain why nothing was responsive under your old script, but there's probably something in there I didn't catch when scanning through it here.
Re: Lockloc groups and changing rotation
Posted: Thu Nov 03, 2016 4:37 am
by cusingerBUSCw5N
thanks for the explanation!
Re: Lockloc groups and changing rotation
Posted: Sun Nov 06, 2016 4:50 am
by cusingerBUSCw5N
I have spent a lot of time comparing scrollers and changing rotation. I would have thought that scrolling and rotating would have been debugged and simple to implement by now... but apparently not.
I have about 20 in my stack and all work "sometimes"....
1) On Android, the scroller wouldn't work until I removed the instructions to set the label of a button - which occurred right before it went to a new card. It makes no sense why that would affect a scroller on the next card..but it did. It didn't crash the whole application - but the scroller wouldn't work.
2) On IOS, the scroller breaks in landscape if I put a url(turl) call within the layoutcontrols. It works when you first have it in landscape, but when you rotate the device, it breaks and crashes the whole system. Remove url(turl) and it works. That doesn't make any sense either. ---- url(turl) in a button on the same card works just fine.
3) And just for the record - on another post - url(turl) doesn't work in 8.1.1. I upgraded to 9.0 and it works (although it breaks the scroller).
4) I reported earlier that the same script for a group scrolling and rotating didn't resize - while individual fields without the scrolling rotated and resized just fine.
So...I'm just reporting that scrollers are very fragile. They apparently only work if you're moving things around in layoutcontrols... but not if you're doing anything else. So I guess the only workaround is to do all other actions in preopen stack. It would really be helpful to have specific examples or rules for scrollers - since this has taken over two weeks of comparing scrollers - some which work and some which don't - all using basically the same script.