port examples to new events

This commit is contained in:
Evan Almloff committed 2023-09-01 15:38:55 -05:00
1 parent dee92b83be
commit df222c121a
25 files changed
+55 -41

No files matched your search

+1 -1
View File
@@ -78,7 +78,7 @@ toml_edit = "0.19.11"
# dioxus-rsx = "0.0.1"
# bundling
tauri-bundler = { version = "1.2", features = ["native-tls-vendored"] }
tauri-bundler = { version = "=1.2", features = ["native-tls-vendored"] }
tauri-utils = "1.3"
dioxus-autofmt = { workspace = true }
+8 -1
View File
@@ -56,7 +56,14 @@ fn events_generate() {
let mut dom = VirtualDom::new(app);
_ = dom.rebuild();
dom.handle_event("click", Rc::new(MouseData::default()), ElementId(1), true);
dom.handle_event(
"click",
Rc::new(PlatformEventData::new(Box::new(MouseData::new(
SerializedMouseData::default(),
)))),
ElementId(1),
true,
);
dom.mark_dirty(ScopeId(0));
let edits = dom.render_immediate();
+8 -1
View File
@@ -9,7 +9,14 @@ fn miri_rollover() {
_ = dom.rebuild();
for _ in 0..3 {
dom.handle_event("click", Rc::new(MouseData::default()), ElementId(2), true);
dom.handle_event(
"click",
Rc::new(PlatformEventData::new(Box::new(MouseData::new(
SerializedMouseData::default(),
)))),
ElementId(2),
true,
);
dom.process_events();
_ = dom.render_immediate();
}
+1 -1
View File
@@ -36,7 +36,7 @@ fn suspended_child(cx: Scope) -> Element {
cx.spawn(async move {
val += 1;
});
return cx.suspend()?;
cx.suspend()?;
}
render!("child")
+3 -3
View File
@@ -304,7 +304,7 @@ fn app(cx: Scope) -> Element {
assert!(event.data.modifiers().is_empty());
assert_eq!(event.data.key().to_string(), "a");
assert_eq!(event.data.code().to_string(), "KeyA");
assert_eq!(event.data.location, 0);
assert_eq!(event.data.location(), Location::Standard);
assert!(event.data.is_auto_repeating());
recieved_events.modify(|x| *x + 1)
@@ -317,7 +317,7 @@ fn app(cx: Scope) -> Element {
assert!(event.data.modifiers().is_empty());
assert_eq!(event.data.key().to_string(), "a");
assert_eq!(event.data.code().to_string(), "KeyA");
assert_eq!(event.data.location, 0);
assert_eq!(event.data.location(), Location::Standard);
assert!(!event.data.is_auto_repeating());
recieved_events.modify(|x| *x + 1)
@@ -330,7 +330,7 @@ fn app(cx: Scope) -> Element {
assert!(event.data.modifiers().is_empty());
assert_eq!(event.data.key().to_string(), "a");
assert_eq!(event.data.code().to_string(), "KeyA");
assert_eq!(event.data.location, 0);
assert_eq!(event.data.location(), Location::Standard);
assert!(!event.data.is_auto_repeating());
recieved_events.modify(|x| *x + 1)
+5 -5
View File
@@ -18,7 +18,7 @@ fn app(cx: Scope) -> Element {
justify_content: "center",
input {
oninput: |data| if &data.value == "good"{
oninput: |data| if &data.value()== "good"{
bg_green.set(true);
} else{
bg_green.set(false);
@@ -30,7 +30,7 @@ fn app(cx: Scope) -> Element {
checked: "true",
}
input {
oninput: |data| if &data.value == "hello world"{
oninput: |data| if &data.value()== "hello world"{
bg_green.set(true);
} else{
bg_green.set(false);
@@ -41,7 +41,7 @@ fn app(cx: Scope) -> Element {
}
input {
oninput: |data| {
if (data.value.parse::<f32>().unwrap() - 40.0).abs() < 5.0 {
if (data.value().parse::<f32>().unwrap() - 40.0).abs() < 5.0 {
bg_green.set(true);
} else{
bg_green.set(false);
@@ -55,7 +55,7 @@ fn app(cx: Scope) -> Element {
}
input {
oninput: |data| {
if data.value == "10"{
if data.value()== "10"{
bg_green.set(true);
} else{
bg_green.set(false);
@@ -68,7 +68,7 @@ fn app(cx: Scope) -> Element {
}
input {
oninput: |data| {
if data.value == "hello world"{
if data.value()== "hello world"{
bg_green.set(true);
} else{
bg_green.set(false);
+1 -1
View File
@@ -46,5 +46,5 @@ pub mod prelude {
pub use crate::eval::*;
pub use crate::events::*;
pub use crate::point_interaction::PointInteraction;
pub use keyboard_types::{self, Code, Key, Modifiers};
pub use keyboard_types::{self, Code, Key, Location, Modifiers};
}
+1 -1
View File
@@ -225,7 +225,7 @@ impl EventData {
fn test_back_and_forth() {
let data = HtmlEvent {
element: ElementId(0),
data: EventData::Mouse(SerializedMouseData::default().into()),
data: EventData::Mouse(SerializedMouseData::default()),
name: "click".to_string(),
bubbles: true,
};
+1 -1
View File
@@ -80,7 +80,7 @@ fn Route3(cx: Scope, dynamic: String) -> Element {
render! {
input {
oninput: move |evt| {
*current_route_str.write() = evt.value.clone();
*current_route_str.write() = evt.value();
},
value: "{current_route_str.read()}"
}