rust - 如何删除 OrbTk 中的小部件?
问题描述
我能够使用 OrbTk 的开发版本(不是 crates.io 上的那个)制作带有标签和按钮的基本 GUI。现在,我想在单击该按钮时删除标签和按钮。
我查看了 GitHub 上的示例,以及 docs.rs 上的 OrbTk 文档,但这些小部件似乎没有功能delete()
或remove()
除了 Grid。
所以我把小部件放在一个网格中,希望我可以通过执行来清除整个网格grid.clear()
。但现在在我的代码中,该函数clear()
似乎不存在......
它虽然写在文档中。
代码:
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();
}
货物.toml:
[package]
name = "orb_tk"
version = "0.1.0"
authors = ["Niel"]
edition = "2018"
[dependencies]
orbtk = { git = "https://github.com/redox-os/orbtk.git", branch= "develop" }
似乎在我使用的 OrbTk 的新开发版本中Grid
不再具有remove()
orclear()
功能。不,我根本不知道如何删除小部件。
如何删除 OrbTk 中的一个小部件或一组小部件?
解决方案
推荐阅读
- javascript - 如何在 ReactJS 中使用 filter() 从数组中删除一项 - 函数无法正常工作
- xamarin - 是否可以在 Xamarin 中使用 Google Cloud Vision Nuget 突出显示检测到的文本?
- asp.net - 如何在颤动中从 api url 加载图像?
- c# - 如何保存不同类型的值而不转换它们,从而在 C# 中丢失它们的特定字段/方法?
- bash - 将参数传递给 bash 别名
- java - Android url Api 按环境
- angular - 一个应用程序中的多个 ngrx 存储实例
- datetime - 创建只有年、月和日的 DateTime.now() 的最佳方法?
- laravel - laravel 中的多个位置
- sql - SQL 查询以获取只有一个值的项目