Remove ViewContext::dispatch_action
This commit is contained in:
parent
d815fc88ae
commit
c4472b0786
41 changed files with 574 additions and 670 deletions
|
@ -1745,10 +1745,6 @@ impl AppContext {
|
|||
self.pending_effects.push_back(Effect::RefreshWindows);
|
||||
}
|
||||
|
||||
fn dispatch_action_at(&mut self, window_id: usize, view_id: usize, action: impl Action) {
|
||||
self.dispatch_any_action_at(window_id, view_id, Box::new(action));
|
||||
}
|
||||
|
||||
pub fn dispatch_any_action_at(
|
||||
&mut self,
|
||||
window_id: usize,
|
||||
|
@ -3189,13 +3185,6 @@ impl<'a, 'b, V: View> ViewContext<'a, 'b, V> {
|
|||
self.window_context.notify_view(window_id, view_id);
|
||||
}
|
||||
|
||||
pub fn dispatch_action(&mut self, action: impl Action) {
|
||||
let window_id = self.window_id;
|
||||
let view_id = self.view_id;
|
||||
self.window_context
|
||||
.dispatch_action_at(window_id, view_id, action)
|
||||
}
|
||||
|
||||
pub fn defer(&mut self, callback: impl 'static + FnOnce(&mut V, &mut ViewContext<V>)) {
|
||||
let handle = self.handle();
|
||||
self.window_context
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
actions, elements::*, impl_actions, platform::MouseButton, AppContext, Entity, EventContext,
|
||||
View, ViewContext, WeakViewHandle,
|
||||
actions, elements::*, impl_actions, platform::MouseButton, AppContext, Entity, View,
|
||||
ViewContext, WeakViewHandle,
|
||||
};
|
||||
|
||||
pub struct Select {
|
||||
|
@ -116,10 +116,9 @@ impl View for Select {
|
|||
.contained()
|
||||
.with_style(style.header)
|
||||
})
|
||||
.on_click(
|
||||
MouseButton::Left,
|
||||
move |_, _, cx: &mut EventContext<Self>| cx.dispatch_action(ToggleSelect),
|
||||
),
|
||||
.on_click(MouseButton::Left, move |_, this, cx| {
|
||||
this.toggle(&Default::default(), cx);
|
||||
}),
|
||||
);
|
||||
if self.is_open {
|
||||
result.add_child(Overlay::new(
|
||||
|
@ -143,12 +142,9 @@ impl View for Select {
|
|||
cx,
|
||||
)
|
||||
})
|
||||
.on_click(
|
||||
MouseButton::Left,
|
||||
move |_, _, cx: &mut EventContext<Self>| {
|
||||
cx.dispatch_action(SelectItem(ix))
|
||||
},
|
||||
)
|
||||
.on_click(MouseButton::Left, move |_, this, cx| {
|
||||
this.select_item(&SelectItem(ix), cx);
|
||||
})
|
||||
.into_any()
|
||||
}))
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue