0

为什么我的按钮不在框面板内的 0x0 处?

main: layout [
    size 680x400
    origin 0x0
    space 0x0
    pad 0x0
    at 0x0

    across       
    Menu1: box brick 200x200
    return     
    Menu2: box blue 200x300
]


Menu1-items: layout [
    origin 0x0
    space 0x0
    at 0x0
    button "1"
    button "2"
    button "Quit" [quit]
]

Menu2-items: layout [
    origin 0x0
    space 0x0
    at 0x0
    button "3"
    button "4"
]    
Menu1/pane: Menu1-items
Menu2/pane: Menu2-items
Show Menu1
Show Menu2

View Main
4

2 回答 2

1

menu1-items 布局本身有一个默认偏移量。菜单 2 项同上。

有两种方法可以解决这个问题。我对 menu1-items 使用了一种方法,对 menu2-items 使用了另一种方法。选择你喜欢的一个:

main: layout [
    size 680x400
    origin 0x0
    space 0x0
    pad 0x0
    at 0x0

    across       
    Menu1: box brick 200x200
    return     
    Menu2: box blue 200x300
]


Menu1-items: layout/offset [    ;; added /offset
    origin 0x0
    space 0x0
    at 0x0
    b1: button "1"
    button "2"
    button "Quit" [quit]
] 0x0                           ;; added 0x0 for value of /offset refinement

Menu2-items: layout [
    origin 0x0
    space 0x0
    at 0x0
    button "3"
    button "4"
]    

menu2-items/offset: 0x0         ;; inserted setting of /offset variable
Menu1/pane: Menu1-items
Menu2/pane: Menu2-items
Show Menu1
Show Menu2


View Main
于 2009-07-28T15:12:50.000 回答
1

另一个类似的解决方案是使用 /tight 的布局细化,如下所示:

Menu1-items: layout/tight [
    space 0x0
    button "1"
    button "2"
    button "Quit" [quit]
]

Menu2-items: layout/tight [
    space 0x0
    button "3"
    button "4"
]

另一种方法是使用 PANEL 元素而不是 BOX 将子布局内联在一个大块中。

于 2009-08-19T13:44:18.827 回答