Skip to content

Commit

Permalink
Add enable_prevent_default option. (#1286)
Browse files Browse the repository at this point in the history
Co-authored-by: Ghislain PUTOIS <ghislain.putois@gmail.com>
  • Loading branch information
ghpu and Ghislain PUTOIS authored Jun 4, 2020
1 parent 5bcf36d commit ec08c6f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions yew/src/services/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cfg_if! {
use stdweb::web::event::{ConcreteEvent, KeyDownEvent, KeyPressEvent, KeyUpEvent};
use stdweb::web::{EventListenerHandle, IEventTarget};
} else if #[cfg(feature = "web_sys")] {
use gloo::events::EventListener;
use gloo::events::{EventListener,EventListenerOptions};
use wasm_bindgen::JsCast;
use web_sys::{Event, EventTarget, KeyboardEvent};
}
Expand Down Expand Up @@ -138,8 +138,13 @@ fn register_key_impl<T: AsRef<EventTarget>>(
.clone();
callback.emit(event);
};

KeyListenerHandle(EventListener::new(element.as_ref(), event, listener))
let options = EventListenerOptions::enable_prevent_default();
KeyListenerHandle(EventListener::new_with_options(
element.as_ref(),
event,
options,
listener,
))
}

#[cfg(feature = "std_web")]
Expand Down

0 comments on commit ec08c6f

Please sign in to comment.