afia_component/dom/dialog.rs
1//! Methods related to dialog elements.
2
3use crate::dom::element::DomElement;
4
5impl DomElement {
6 /// Open the dialog element as a modal
7 ///
8 /// TODO: Consider having more type safety to reduce the likelihood of
9 /// calling this on something that isn't a dialog.
10 /// One possible idea would be to have a DialogElement type and put the
11 /// show_modal and close methods on the DialogElement type and then have a
12 /// way to cast between types.
13 pub fn dialog_show_modal(&self) {
14 unsafe {
15 afia_component_sys::dialog_element_show_modal(
16 self.component_imports_ptr(),
17 self.to_i64(),
18 )
19 };
20 }
21
22 /// Close the dialog element as a modal
23 pub fn dialog_close(&self) {
24 unsafe {
25 afia_component_sys::dialog_element_close(self.component_imports_ptr(), self.to_i64())
26 };
27 }
28}