Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 有没有办法在Rebol中居中gui按钮和字段?_User Interface_Rebol_Rebol2 - Fatal编程技术网

User interface 有没有办法在Rebol中居中gui按钮和字段?

User interface 有没有办法在Rebol中居中gui按钮和字段?,user-interface,rebol,rebol2,User Interface,Rebol,Rebol2,花了好几个小时想弄明白,但还是没弄明白。所有文档都没有提到它。这是不是rebol在没有手动重新安排origin的情况下无法做到的 也许我只是期望太高了 编辑:我发现了一个hack:indent-num,然后在下一行找到indent-num。在这种语言的所有引人注目的特性中,为什么他们不能添加一个简单的命令,如center?首先,VID不是Rebol,而是作者Carl Sassenrath编写的一种演示方言,用于演示如何用Rebol对接口进行方言化。还有其他一些,包括RebGUI(),但我怀疑也没

花了好几个小时想弄明白,但还是没弄明白。所有文档都没有提到它。这是不是rebol在没有手动重新安排origin的情况下无法做到的

也许我只是期望太高了


编辑:我发现了一个hack:indent-num,然后在下一行找到indent-num。在这种语言的所有引人注目的特性中,为什么他们不能添加一个简单的命令,如center?

首先,VID不是Rebol,而是作者Carl Sassenrath编写的一种演示方言,用于演示如何用Rebol对接口进行方言化。还有其他一些,包括RebGUI(),但我怀疑也没有办法将按钮居中,因为两位作者都不认为这很重要


您也可以使用PAD将光标对准布局的中心。

有一个中心面功能,您可以重新使用它来对齐面,但不幸的是,根据我的经验,它不能很好地工作。下面是一个更简单的替换版本,可以实现以下功能:

center-face: func [face [object!] parent [object!]][
    face/offset: parent/size - face/size / 2 
]
rebol []

center: func [face][
    face/offset/x: (face/parent-face/size/x / 2) - (face/size/x / 2)
    show face
]

view/new layout [
    across
    t: h1  "This is a centered title!" 
    return
    button "1"
    button "2"
    button "3"
    button "4"
]

center t

do-events
下面是一个使用示例:

lay: layout [
    size 300x300
    b: button "Hello World"
]
center-face b lay
view lay

我们不能基于窗口本身来居中或对齐对象,因为控件在父面上调用“SHOW”后才能引用其父面

面/父面在显示父面之前不会设置。因此,在普通视频中,您需要在完成初始布局和视图之后调整gui

下面是一个小脚本,它演示了在至少显示一次面之后如何将其居中

view/new用于延迟事件处理,以便修改布局

rebol []

center: func [face][
    face/offset/x: (face/parent-face/size/x / 2) - (face/size/x / 2)
    show face
]

view/new layout [
    across
    t: h1  "This is a centered title!" 
    return
    button "1"
    button "2"
    button "3"
    button "4"
]

center t

do-events

RebGUI中的Span指令可用于在布局中对齐小部件。以上事实上会给你错误…'LAY没有布局块中的值。