WIP
This commit is contained in:
@@ -22,7 +22,8 @@ where
|
||||
A: for<'a> Deserialize<'a> + PartialEq + Clone + Default + 'static,
|
||||
{
|
||||
fn qualified_name() -> SharedString {
|
||||
type_name::<A>().into()
|
||||
// todo!() remove this
|
||||
type_name::<A>().replace("2::", "::").into()
|
||||
}
|
||||
|
||||
fn build(params: Option<serde_json::Value>) -> Result<Box<dyn Action>>
|
||||
|
||||
+12
-2
@@ -779,11 +779,21 @@ impl AppContext {
|
||||
(build)(params)
|
||||
}
|
||||
|
||||
/// Halt propagation of a mouse event, keyboard event, or action. This prevents listeners
|
||||
/// that have not yet been invoked from receiving the event.
|
||||
/// Event handlers propagate events by default. Call this method to stop dispatching to
|
||||
/// event handlers with a lower z-index (mouse) or higher in the tree (keyboard). This is
|
||||
/// the opposite of [propagate]. It's also possible to cancel a call to [propagate] by
|
||||
/// calling this method before effects are flushed.
|
||||
pub fn stop_propagation(&mut self) {
|
||||
self.propagate_event = false;
|
||||
}
|
||||
|
||||
/// Action handlers stop propagation by default during the bubble phase of action dispatch
|
||||
/// dispatching to action handlers higher in the element tree. This is the opposite of
|
||||
/// [stop_propagation]. It's also possible to cancel a call to [stop_propagate] by calling
|
||||
/// this method before effects are flushed.
|
||||
pub fn propagate(&mut self) {
|
||||
self.propagate_event = true;
|
||||
}
|
||||
}
|
||||
|
||||
impl Context for AppContext {
|
||||
|
||||
@@ -1314,6 +1314,7 @@ impl<'a> WindowContext<'a> {
|
||||
} = stack_frame
|
||||
{
|
||||
if action_type == *event_type {
|
||||
self.app.propagate_event = false;
|
||||
listener(action.as_any(), &[], DispatchPhase::Bubble, self);
|
||||
if !self.app.propagate_event {
|
||||
break;
|
||||
@@ -1328,6 +1329,7 @@ impl<'a> WindowContext<'a> {
|
||||
self.app.global_action_listeners.remove(&action_type)
|
||||
{
|
||||
for listener in global_listeners.iter().rev() {
|
||||
self.app.propagate_event = false;
|
||||
listener(action.as_ref(), DispatchPhase::Bubble, self);
|
||||
if !self.app.propagate_event {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user