diff options
author | 2023-04-17 23:46:18 +0200 | |
---|---|---|
committer | 2023-04-17 23:46:18 +0200 | |
commit | 619ba9294d5e0f7913f82838d78018fc6714d26a (patch) | |
tree | b0631aa66875e0e9f486665227c306832ac19a5b /examples/integration/src | |
parent | d206b82ebb7617337cd378bd19542a7abf8a4529 (diff) | |
parent | e3730106e9d4f75de199e1b83cf285b8ff031968 (diff) | |
download | iced-619ba9294d5e0f7913f82838d78018fc6714d26a.tar.gz iced-619ba9294d5e0f7913f82838d78018fc6714d26a.tar.bz2 iced-619ba9294d5e0f7913f82838d78018fc6714d26a.zip |
Merge branch 'advanced-text' into incremental-rendering
Diffstat (limited to 'examples/integration/src')
-rw-r--r-- | examples/integration/src/controls.rs | 9 | ||||
-rw-r--r-- | examples/integration/src/main.rs | 14 |
2 files changed, 13 insertions, 10 deletions
diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs index 5849f730..14e53ede 100644 --- a/examples/integration/src/controls.rs +++ b/examples/integration/src/controls.rs @@ -102,11 +102,10 @@ impl Program for Controls { .size(14) .style(Color::WHITE), ) - .push(text_input( - "Placeholder", - text, - Message::TextChanged, - )), + .push( + text_input("Placeholder", text) + .on_input(Message::TextChanged), + ), ), ) .into() diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 949a726a..98d2bc59 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -30,6 +30,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(target_arch = "wasm32")] let canvas_element = { console_log::init_with_level(log::Level::Debug)?; + std::panic::set_hook(Box::new(console_error_panic_hook::hook)); web_sys::window() @@ -49,7 +50,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> { .build(&event_loop)?; #[cfg(not(target_arch = "wasm32"))] - let window = winit::window::Window::new(&event_loop).unwrap(); + let window = winit::window::Window::new(&event_loop)?; let physical_size = window.inner_size(); let mut viewport = Viewport::with_physical_size( @@ -61,7 +62,6 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> { let mut clipboard = Clipboard::connect(&window); // Initialize wgpu - #[cfg(target_arch = "wasm32")] let default_backend = wgpu::Backends::GL; #[cfg(not(target_arch = "wasm32"))] @@ -95,12 +95,16 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(not(target_arch = "wasm32"))] let needed_limits = wgpu::Limits::default(); + let capabilities = surface.get_capabilities(&adapter); + ( - surface - .get_capabilities(&adapter) + capabilities .formats - .first() + .iter() + .filter(|format| format.describe().srgb) .copied() + .next() + .or_else(|| capabilities.formats.first().copied()) .expect("Get preferred format"), adapter .request_device( |