You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next, we construct a [`MessageBox`] widget, then wrap with a [`Window`]:
30
-
```rust
31
-
# externcrate kas;
32
-
# usekas::widgets::dialog::MessageBox;
33
-
letwindow=MessageBox::new("Message")
34
-
.into_window("Hello world");
35
-
# let_:kas::Window<()> =window;
36
-
```
32
+
We use the [`column!`] macro to construct our layout. This macro turns string literals into label widgets for us, ensuring that "Hello, world!" will appear on the screen.
37
33
38
-
Finally, we construct a default app, add this window, and run:
For the button, we use a [`Button`] widget. The button's action handler calls [`EventState::exit`] to terminate the UI. (To close the window without terminating the UI, we would instead call `cx.window_action(Action::CLOSE);`.)
49
35
50
-
[`kas::app::Default`] is just a parameterisation of [`kas::app::Application`] which selects a sensible graphics backend and theme.
36
+
## The Window
51
37
52
-
If you wanted to select your own theme instead, you could do so as follows:
We construct a [`Window`] over the `ui` and a title. We also call [`Window::escapable`] to allow our window to be closed using the <kbd>Escape</kbd> key.
65
39
66
-
Or, if you wanted to specify the graphics backend and theme:
Every UI needs a [`Runner`]. In this example we simply construct a runner over data `()`, add a single window, and run. In later examples you will see how we can select a theme, use input data, multiple windows and tweak the configuration.
79
43
80
-
Finally, [`Application::run`] starts our UI. This method runs the event-loop internally, returning `Ok(())` once all windows have closed successfully.
44
+
Finally, [`Runner::run`] starts our UI. This method runs the event-loop internally, returning `Ok(())` once all windows have closed successfully.
0 commit comments