用红色语言隐藏和取消隐藏视图

时间:2017-10-09 01:53:24

标签: window red

我正在尝试使用代码来创建第二个视图,该视图可以隐藏并重复显示,同时保留其字段中的值:

Red []

secondFstr: ""
secondshownonce: false
secondshowing: false

secondview: does [
    secondshownonce: true
    if not secondshowing [
      secondshowing: true
      view [ below
        text "second view"
        f2: field secondFstr []
        b3: button "Hide" [
            secondshowing: false
            unview ]]]]

view [ below
    text "first view"
    b1: button "Print f2 text" [
          either not secondshownonce 
            [print "not shown"]
            [print f2/text] ]
    b2: button "Show 2nd view" [secondview] ]

如果“隐藏”按钮用于第二个视图,它可以正常工作。但如果通过单击右上角的“x”关闭第二个视图,则无法再次显示。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您需要在该子窗口上为close事件添加处理程序,以便正确重置您的标记,如下所示:

view/options [
    below
    text "second view"
    f2: field secondFstr []
    b3: button "Hide" [
        secondshowing: false
        unview
    ]
][
    actors: object [
        on-close: func [face event][
            secondshowing: false
        ]
    ]
]