Merge branch 'master' into jk/templates-v3

This commit is contained in:
Jonathan Kelley committed 2022-11-16 22:12:16 -08:00
commit c1c5821dcf
9 files changed
+36 -86

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ tokio = { version = "1.16.1", features = [
"rt",
"time",
], optional = true, default-features = false }
webbrowser = "0.7.1"
webbrowser = "0.8.0"
infer = "0.9.0"
dunce = "1.0.2"
+7 -1
View File
@@ -182,7 +182,13 @@ pub(super) fn handler(
) {
// currently dioxus-desktop supports a single window only,
// so we can grab the only webview from the map;
let webview = desktop.webviews.values().next().unwrap();
// on wayland it is possible that a user event is emitted
// before the webview is initialized. ignore the event.
let webview = if let Some(webview) = desktop.webviews.values().next() {
webview
} else {
return;
};
let window = webview.window();
println!("user_event: {:?}", user_event);
-2
View File
@@ -18,8 +18,6 @@ pub(super) fn desktop_handler(
custom_head: Option<String>,
custom_index: Option<String>,
) -> Result<Response<Vec<u8>>> {
println!("loading request: {:?}", request.uri());
// Any content that uses the `dioxus://` scheme will be shuttled through this handler as a "special case".
// For now, we only serve two pieces of content which get included as bytes into the final binary.
let path = request.uri().to_string().replace("dioxus://", "");
-1
View File
@@ -88,7 +88,6 @@ impl Parse for BodyNode {
// crate::Input::<InputProps<'_, i32> {}
if body_stream.peek(token::Brace) {
Component::validate_component_path(&path)?;
return Ok(BodyNode::Component(stream.parse()?));
}
}
File renamed without changes.
-66
View File
@@ -1,66 +0,0 @@
use dioxus::events::WheelEvent;
use dioxus::prelude::*;
use dioxus_html::geometry::ScreenPoint;
use dioxus_html::input_data::keyboard_types::Code;
use dioxus_html::input_data::MouseButtonSet;
use dioxus_html::on::{KeyboardEvent, MouseEvent};
fn main() {
dioxus_tui::launch(app);
}
fn app(cx: Scope) -> Element {
let key = use_state(&cx, || "".to_string());
let mouse = use_state(&cx, ScreenPoint::zero);
let count = use_state(&cx, || 0);
let buttons = use_state(&cx, MouseButtonSet::empty);
let mouse_clicked = use_state(&cx, || false);
let key_down_handler = move |evt: KeyboardEvent| {
match evt.data.code() {
Code::ArrowLeft => count.set(count + 1),
Code::ArrowRight => count.set(count - 1),
Code::ArrowUp => count.set(count + 10),
Code::ArrowDown => count.set(count - 10),
_ => {}
}
key.set(format!(
"{:?} repeating: {:?}",
evt.key(),
evt.is_auto_repeating()
));
};
cx.render(rsx! {
div {
width: "100%",
height: "10px",
background_color: "red",
justify_content: "center",
align_items: "center",
flex_direction: "column",
onkeydown: key_down_handler,
onwheel: move |evt: WheelEvent| {
count.set(count + evt.data.delta().strip_units().y as i64);
},
ondrag: move |evt: MouseEvent| {
mouse.set(evt.data.screen_coordinates());
},
onmousedown: move |evt: MouseEvent| {
mouse.set(evt.data.screen_coordinates());
buttons.set(evt.data.held_buttons());
mouse_clicked.set(true);
},
onmouseup: move |evt: MouseEvent| {
buttons.set(evt.data.held_buttons());
mouse_clicked.set(false);
},
"count: {count:?}",
"key: {key}",
"mouse buttons: {buttons:?}",
"mouse pos: {mouse:?}",
"mouse button pressed: {mouse_clicked}"
}
})
}