diff --git a/crates/story/src/popup_story.rs b/crates/story/src/popup_story.rs index 9643a06c..f3240ede 100644 --- a/crates/story/src/popup_story.rs +++ b/crates/story/src/popup_story.rs @@ -14,7 +14,7 @@ use ui::{ popover::{Popover, PopoverContent}, popup_menu::PopupMenuExt, switch::Switch, - v_flex, IconName, Sizable, + v_flex, ContextModal, IconName, Sizable, }; #[derive(Clone, PartialEq, Deserialize)] @@ -309,10 +309,32 @@ impl Render for PopupStory { ) .child(Divider::horizontal()) .child( - Button::new("info1", cx) - .label("Yes") - .w(px(80.)) - .small(), + h_flex() + .gap_4() + .child( + Button::new("info1", cx) + .label("Ok") + .w(px(80.)) + .small() + .on_click(cx.listener( + |_, _, cx| { + cx.push_notification( + "You have clicked Ok.", + ); + cx.emit(DismissEvent); + }, + )), + ) + .child( + Button::new("close", cx) + .label("Cancel") + .small() + .on_click(cx.listener( + |_, _, cx| { + cx.emit(DismissEvent); + }, + )), + ), ) .into_any() }) diff --git a/crates/ui/src/popover.rs b/crates/ui/src/popover.rs index 82ee0f7a..0eccae26 100644 --- a/crates/ui/src/popover.rs +++ b/crates/ui/src/popover.rs @@ -19,14 +19,14 @@ pub fn init(cx: &mut AppContext) { pub struct PopoverContent { focus_handle: FocusHandle, - content: Rc AnyElement>, + content: Rc) -> AnyElement>, max_width: Option, } impl PopoverContent { pub fn new(cx: &mut WindowContext, content: B) -> Self where - B: Fn(&mut WindowContext) -> AnyElement + 'static, + B: Fn(&mut ViewContext) -> AnyElement + 'static, { let focus_handle = cx.focus_handle();