【问题标题】:Can LiveCode objects be anchored to one or more sides of a form?LiveCode 对象可以锚定到表单的一侧或多侧吗?
【发布时间】:2013-07-08 23:42:49
【问题描述】:

如果是这样,怎么做? ...为了清楚起见,如果表单和对象的边缘之间有 2 个像素,并且我调整了表单的大小,我希望在调整大小后表单和对象之间的距离仍然是 2 个像素。

谢谢你,一如既往。

【问题讨论】:

  • 应该调整对象的大小还是重新定位?
  • @Splash21 -- 我在想后者,但很高兴了解两者。

标签: livecode


【解决方案1】:

有几种方法可以做到这一点,但最简单和最可靠的是在您的卡片脚本中使用 resizeStack 处理程序编写脚本:

on resizeStack pWidth,pHeight
  put the rect of field "name" into tRect
  put pWidth-2 into item 3 of tRect
  set the rect of field "name" to tRect
end resizeStack

【讨论】:

  • 这给了我需要的信息。谢谢你。 (我想我已经被 IDE 和语言宠坏了,这些语言的属性为开发人员做了很多工作!)
【解决方案2】:

如果您正在做的事情是在调整堆栈窗口的大小时将对象保持在所需的排列中,Monte 的回答是完全正确的。但是,如果您想知道如何在卡片布局中调整或移动对象或对象组(您说“表单”,所以我假设这是一组对象)的大小或移动时保持相对定位,您只需在卡片布局中更新它用于调整表单或组大小的相同代码。

constant kOffset

on resizeMyGroup
  -- code for resizing group here
  set the left of button "myButton" to the right of group "myForm" + kMargin
  set the bottom of button "myButton" to the bottom of group "myForm"
  -- etc.
end resizeMyGroup

这是在 LiveCode 中维护布局的一般方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-05
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多