【发布时间】:2013-03-08 05:52:05
【问题描述】:
我想滚动字段,以便在调整大小后可以看到选择。为此,我需要计算所选字段顶部的高度,然后偏移当前滚动以计算出新滚动。我不能假设一个固定的LineHeight。谁有线索?
【问题讨论】:
-
Gian 感谢您的编辑,但这不是 iOS 特定的。 LiveCode 是跨平台的。不幸的是,还没有 LiveCode 标签。
标签: ios user-experience livecode
我想滚动字段,以便在调整大小后可以看到选择。为此,我需要计算所选字段顶部的高度,然后偏移当前滚动以计算出新滚动。我不能假设一个固定的LineHeight。谁有线索?
【问题讨论】:
标签: ios user-experience livecode
在字典中搜索后,我找到了 selectedLoc 函数。我最终在每次调整字段大小后执行了以下代码,这给出了我想要的行为。
put item 2 of the selectedLoc-the scroll of pField into tSelectionHeight
if tSelectionHeight > the scroll of pField+the height of pField then
set the scroll of pField to tSelectionHeight-the height of pField
end if
【讨论】:
如果没有选定的位置,以下方法也有效。我在 PowerDebug 中使用它来将断点或当前代码行置于调试窗口的中心。 (是的,我意识到我假设 lineheight 在现场是一致的)。
command CenterDebugText pLinesToHilite
local tLineHeight, tFieldHeight
local tScroll
lock screen
set the hilitedlines of field kDebugFieldName of me to pLinesToHilite
-- center the breakpoint line in the display
-- calculate the number of visible script lines
put the effective textheight of field kDebugFieldName into tLineHeight
put the height of field kDebugFieldName into tFieldHeight
put tLineHeight * (item 1 of pLinesToHilite) into tScroll
subtract tFieldHeight / 2 from tScroll
set the vscroll of field kDebugFieldName to trunc(tScroll)
unlock screen
end CenterDebugText
【讨论】: