Remove button faces

195 Views Asked by At

Hi all.
I want to know that how can I remove two button face with a button.

I tried this:

gui: [
  en: button "English" remove [en es]
  es: button "Spanih" remove [en es]
]

And than I have to append new buttons.

2

There are 2 best solutions below

2
Maciej Łoziński On BEST ANSWER

You can try this:

Red [Needs: View]
view [
    en: button "English" [remove find face/parent/pane en]
    es: button "Spanish" [
        remove find face/parent/pane en
        remove find face/parent/pane es
    ]
]
1
9214 On

View engine models GUI interface as a tree of objects; each node in that tree is called a face, and each field of that face is called a facet.

Two facets, parent and pane, interlink a face with its parent node and its child nodes, respectively. So, by that theory, to remove a button is to remove a button face from a pane of its parent:

view [button "Poof!" [probe select take face/parent/pane 'text]]

This, however, is a bit limited approach. The removed face is detached from View tree and can no longer be used unless you reattach the face! object with the same specification back to the pane. It might be more useful to simply disable a button, or to render it invisible for the time being. enabled? and visible? facets can achieve just that:

view [
    title "Face flags example"
    below
    toggle "Toggle" [foo/enabled?: not foo/enabled?]
    foo: button "Switch" disabled [bar/visible?: not bar/visible?]
    bar: base red
]

You can adapt this approach to the task at hand. As I understand, you want to offer mutually exclusive localization options; drop-list might be a good fit for that:

view [drop-list data ["en" "es"]]