我想滚动字段,以便在调整大小后可以看到所选内容。为此,我需要计算选定区域顶部的高度,然后偏移当前滚动以计算出新滚动。我不能假设是fixedLineHeight。有谁有什么线索吗?
发布于 2013-03-08 14:15:40
在字典中搜索了一下之后,我找到了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发布于 2013-03-20 04:28:10
在没有选定位置的情况下,以下方法也适用。我在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 CenterDebugTexthttps://stackoverflow.com/questions/15287597
复制相似问题