color_picker: Fix popup does not close by clicking color button again. (#608)
This commit is contained in:
parent
a6922e3a10
commit
b1bae7ca21
1 changed files with 4 additions and 7 deletions
|
|
@ -160,7 +160,6 @@ impl ColorPicker {
|
|||
|
||||
fn on_escape(&mut self, _: &Escape, _: &mut Window, cx: &mut Context<Self>) {
|
||||
cx.propagate();
|
||||
|
||||
self.open = false;
|
||||
cx.notify();
|
||||
}
|
||||
|
|
@ -335,6 +334,10 @@ impl Render for ColorPicker {
|
|||
)
|
||||
.when_some(self.label.clone(), |this, label| this.child(label))
|
||||
.on_click(cx.listener(Self::toggle_picker))
|
||||
.on_mouse_up_out(
|
||||
MouseButton::Left,
|
||||
cx.listener(|view, _, window, cx| view.on_escape(&Escape, window, cx)),
|
||||
)
|
||||
.child(
|
||||
canvas(
|
||||
move |bounds, _, cx| view.update(cx, |r, _| r.bounds = bounds),
|
||||
|
|
@ -367,12 +370,6 @@ impl Render for ColorPicker {
|
|||
.shadow_lg()
|
||||
.rounded(cx.theme().radius)
|
||||
.bg(cx.theme().background)
|
||||
.on_mouse_up_out(
|
||||
MouseButton::Left,
|
||||
cx.listener(|view, _, window, cx| {
|
||||
view.on_escape(&Escape, window, cx)
|
||||
}),
|
||||
)
|
||||
.child(self.render_colors(window, cx)),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue