LiveCode对象可以锚定到表单的一个或多个边吗?

时间:2013-07-08 23:42:49

标签: livecode

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

一如既往地谢谢你。

2 个答案:

答案 0 :(得分:3)

有几种方法可以做到这一点,但最简单和最可靠的方法是使用卡片脚本中的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

答案 1 :(得分:0)

如果你正在做的是在调整堆栈窗口大小时将对象保持在所需的排列中,那么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中维护布局的一般方法。

相关问题