首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用LiveCode字段计算selectedText的位置?

如何使用LiveCode字段计算selectedText的位置?
EN

Stack Overflow用户
提问于 2013-03-08 13:52:05
回答 2查看 239关注 0票数 1

我想滚动字段,以便在调整大小后可以看到所选内容。为此,我需要计算选定区域顶部的高度,然后偏移当前滚动以计算出新滚动。我不能假设是fixedLineHeight。有谁有什么线索吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-08 14:15:40

在字典中搜索了一下之后,我找到了selectedLoc函数。每次调整字段大小后,我都会执行下面的代码,这会给出我想要的行为。

代码语言:javascript
复制
   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
票数 3
EN

Stack Overflow用户

发布于 2013-03-20 04:28:10

在没有选定位置的情况下,以下方法也适用。我在PowerDebug中使用它使断点或当前代码行在调试窗口中居中。(是的,我意识到我假设lineheight在该领域是一致的)。

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15287597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档