Page 1 of 1

Resizing field with scrollbar

Posted: Mon Aug 13, 2012 4:12 pm
by cusingerBUSCw5N
I am working on resizing objects to fit the user's device when a card opens. I have a field that is pulling in information from a sqlite database.
There are more items than I want to show - i.e. I want it to be a scrolling field.

When I manually set up the card, I can get it to scroll and the object stays the size I set it. But when it reloads and goes through my resizing code, the entire list shows - with a lovely scrollbar on the right that is useless because the entire list is showing. First, I tried setting it (see line in bold) to the height of group "task list".... no luck..... Then, I tried setting it to a specific size (100)... no difference.

I don't understand why you set a group height AND a field height.... But I've tried switching things around and nothing makes the list be limited in height with the remainder accessible using the scrollbar.

-- ## Size and position the task list group
set the width of group "task list" of me to tStackWidth
-- set the height of group "task list" of me to (tStackHeight *0.29)
set the top of group "task list" of me to (tStackHeight*0.31)
set the left of group "task list" of me to 0

-- ## Position the task field:
-- set the height of field "tasklist" of me to 100
answer height of field "tasklist"
set the width of field "tasklist" of me to the width of grp "task list" of me
set the topleft of field "tasklist" of me to the topleft of grp "task list" of me
-- put max(30,the height of group "task list" of me/10) into tTextHeight
-- set the textSize of field "tasklist" of me to tTextHeight/2
-- set the textHeight of field "tasklist" of me to tTextHeight
end layoutCard

What am I missing?

Thanks

Re: Resizing field with scrollbar

Posted: Mon Aug 13, 2012 5:32 pm
by shaosean
Is the lockLocation property of the field/group set? When you are adding the lines to the field, is it changing the height of the field at that time?

Re: Resizing field with scrollbar

Posted: Mon Aug 13, 2012 5:40 pm
by Klaus
Adding content to a field does not affect its dimension, so "lockloc" should not matter here.

Re: Resizing field with scrollbar

Posted: Mon Aug 13, 2012 7:55 pm
by cusingerBUSCw5N
So....what does cause it?

Re: Resizing field with scrollbar

Posted: Mon Aug 13, 2012 8:11 pm
by mwieder
Changing the dimensions of controls in a group will change the rect of the group. So setting the height/width of the group *before* changing the field's properties won't have any visible effect. Or rather it will have an effect that will immediately be undone by the changes to the controls within the group.

Re: Resizing field with scrollbar

Posted: Tue Aug 14, 2012 1:16 am
by cusingerBUSCw5N
This is very frustrating. I am modifying portions of the sample Ticked Off application. The original Ticked Off does not have a scrollbar and does not stay in a limited space, and I want to make those two changes. So, I figured out the space issue, but the scrollbar is driving me nuts.

I redid the tasks field using the Scrolling List Field tool. Amazingly, I got a scrollbar and now my field stays where it is supposed to. Very good. However, clicking on the lines no longer takes me to the next card (I copied the same script from the earlier version). Instead, there is a cursor that is sitting in the Scrolling List Field (the one without the scrollbar has no cursor, but on mouse-down goes to the next card).

So...I have one version that sends me to the correct card, but doesn't have a scroll bar.... and other that has a scroll bar without sending me anywhere.

I don't know which one is easier to fix. I either need to know how to add a scroll bar to a list like the one generated on Ticked Off... or I need to know how to select an item in a scrolling list field.....

Here is the object script code that does NOT work for the items in the scroll bar

on showTaskDetails tTaskID

## Set a custom property on the task editor card
## This tells it which task has been selected so the correct details can be shown
set the cTaskID of card "task editor" to tTaskID

visual effect push left fast
go to card "task editor"
end showTaskDetails
## Handlers to detect swipe gestures
## Swiping right marks the task as complete
## Swiping left marks the task as incomplete
## Tapping goes to the task details

local hStart,hEnd, vStart

on mouseUp

put word 2 of the clickline into tTaskID
## Calculate the difference between the start and end point of the gesture
put hEnd - hStart into tDifference

## If we have moved vertically then pass to android scroller
if abs(the mouseV - vStart) > 30 then pass mouseUp

if tDifference > 10 then
## Swipe right
updateTask tTaskID,,,true
buildListDisplay
else if tDifference < -10 then then
## Swipe left
updateTask tTaskID,,,false
buildListDisplay
else
## Tap
showTaskDetails tTaskID
end if
pass mouseUp
end mouseUp

on mouseDown
answer "3"
put word 2 of the clickline into tTaskID -- android hilites line on touch
set the hilitedline of me to tTaskID

# store coords for comparison in mouseUp later:
put the clickH into hStart
put the clickH into hEnd
put the clickV into vStart

# iOS scroller behavior handles this, so we don't need to:
if the environment is "mobile" and the platform is not "android" then
exit mouseDown
else
## to scroller script for desktop & android
pass mouseDown
end if
end mouseDown

on mouseMove x, y
put x into hEnd

## Remove any hiliting while moving
set the hilitedline of me to 0

## Pass to android scroller script
pass mouseMove
end mouseMove

It DOES work if I don't have a scrollbar and use the original Ticked Off, non-scrollbar application.

Someday I will not be this stupid...but today is not the day.

Re: Resizing field with scrollbar

Posted: Tue Aug 14, 2012 1:34 am
by cusingerBUSCw5N
It works now... I added a scrollbar to the original one, and for some reason, it now works.

Re: Resizing field with scrollbar

Posted: Tue Aug 14, 2012 4:59 am
by jacque
If you were seeing an insertion point, the field was not locked. Unlocked fields allow text editing. Locked fields allow mouseUps. To lock a field, set its locktext to true.

The original field had no scrollbar because it was created for iOS where a native scroller control is used instead. iOS doesn't use visible field scrollbars. Desktop apps do use them.