1#![allow(dead_code)]
2
3#[allow(unused)]
4use crate::*;
5use pax_engine::api::*;
6use pax_engine::*;
7
8#[pax]
10#[engine_import_path("pax_engine")]
11#[inlined(
12 if self.open {
13 <Group x=50% y=50% width=300px height=170px>
14 <Button width=80px height=30px anchor_y=100% anchor_x=100% y={100%-20px} x={100% -80px -20px -20px} label="Yes" @button_click=handle_yes/>
15 <Button width=80px height=30px anchor_y=100% anchor_x=100% y={100% -20px} x={100% -20px} label="No" @button_click=handle_no/>
16 <Text x=20px y=20px height=15px width=100px text=text/>
17 <Rectangle fill=rgb(20, 20, 20)
18 corner_radius=15.0/>
19 </Group>
20 <Rectangle fill=rgba(0, 0, 0, 70)/>
21 }
22)]
23#[custom(Default)]
24pub struct ConfirmationDialog {
25 pub text: Property<String>,
27 pub open: Property<bool>,
29 pub _signal: Property<bool>,
31}
32
33impl Default for ConfirmationDialog {
34 fn default() -> Self {
35 Self {
36 text: Property::new("Are you sure?".to_owned()),
37 open: Property::default(),
38 _signal: Property::default(),
39 }
40 }
41}
42
43impl ConfirmationDialog {
44 pub fn handle_yes(&mut self, _ctx: &NodeContext, _event: Event<ButtonClick>) {
46 self.open.set(false);
47 self._signal.set(true);
48 }
49
50 pub fn handle_no(&mut self, _ctx: &NodeContext, _event: Event<ButtonClick>) {
52 self.open.set(false);
53 }
54}