Pass this the long name or ID of the object you want to be visible above the keyboard:
Code: Select all
on setscroll pObj
put item 4 of the effective working screenrect into tKeyboardTop
put the bottom of pObj + tKeyboardTop into tTargetScroll -- may need to fiddle with this a little
set the scroll of grp 1 to tTargetScroll
end setscroll
This will fail if there isn't enough room at the bottom of the group to scroll upward past its last object. That is, you can't scroll the group any higher than the last thing in it. So if your last object is a field, it isn't going to scroll upward enough.
I'd be tempted to just move the whole group maybe. This may get you close, you might have to adjust the scroll of the group a little more:
Code: Select all
on setscroll pObj
put item 4 of the effective working screenrect into tKeyboardTop
put the height of this cd - the top of grp 1 - tKeyboardTop into tOffset
set the scroll of grp 1 to the top of pObj -- probably needs adjusting
set the top of grp 1 to the top of grp 1 - tOffset
end setscroll
Also, you could check the bottom of the object to see if it's already high enough, and you won't have to do anything if it is. The dimensions are returned at the current card coordinates, not the offset of the scrolling group, so all you have to check is "the bottom of field whatever" to know where it is.
Store the correct location of the group before you move it so that you can put it back when the keyboard goes away.
Simon posted before I could. All the above assumes regular LiveCode groups and fields. If you're using native controls there's more to it. I think you'll need to destroy the native controls and rebuild them after you've moved the group or the objects.