Deleting a widget in OrbTk GUI

Hello

I'm playing around with OrbTk. I was able to make a basic GUI with a label and a button. Now, I want to delete the label and button when the button is clicked.

I've looked at the examples on Github, and the documentation for OrbTk on Doc.rs but the widgets do not seem to have a function delete() or remove() except for the Grid.

So I putted the widgets in a grid hoping I could clear the whole grid by executing grid.clear().
But now in my code the function clear() doesn't seem to exist...

It is written in the documentation though.

Code:

use orbtk::*;

widget!(MainView);

//MainView
impl Template for MainView {
    fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
        self.name("MainView").child(
            Grid::create()
                .columns(
                    Columns::create()
                        .column("*").build()
                )
                .rows(
                    Rows::create().row("*").row("*").build()
                )
                .child(
                    TextBlock::create()
                        .text("Label A!")
                        .attach(Grid::row(0))
                        .build(ctx),
                )
                .child(
                    Button::create()
                        .text("My button")
                        .attach(Grid::row(1))
                        .on_click(move |_states, _| -> bool {
                            println!("Rofl");
                            
                            true
                        })
                        .build(ctx),
                )
            .build(ctx)
        )
    }
}

fn main() {
      Application::new()
        .window(|ctx| {
            Window::create()
                .title("OrbTk - minimal example")
                .position((100.0, 100.0))
                .size(420.0, 730.0)
                .child(MainView::create().build(ctx))
                .build(ctx)
        })
        .run();
}

Cargo.toml:

[package]
name = "orb_tk"
version = "0.1.0"
authors = ["Niel"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
orbtk = { git = "https://github.com/redox-os/orbtk.git", branch= "develop" }

How can I delete a widget or a group of widgets in OrbTk? Thanks!

You are using an unreleased git version of orbtk 0.3.x, but you linked to the docs from orbtk 0.2.7. The docs from the latest alpha version are probably closer, or use cargo doc --open to view docs from the git version you are using.

Sorry, I don't know how to remove a widget in orbtk 0.3.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.