egui/crates
Emil Ernerfeldt 3b9f964aed
eframe web: ignore keyboard events unless canvas has focus (#4718)
* Fixes https://github.com/rerun-io/rerun/issues/6638
* Related? https://github.com/emilk/egui/issues/4563

This improves how an eframe canvas works inside of a larger web page,
and how it works when there are multiple eframe apps in the same page.

`eframe` will set `tabindex="0"` on the canvas automatically, making it
focusable.
It will also set `outline: none` on the CSS, so the focused canvas won't
have an ugly outline.


## Breaking changes
You may wanna add this to your `index.html` to give the canvas focus on
startup:
```js
document.getElementById("the_canvas_id").focus();
```

## Test setup
```sh
./scripts/build_demo_web.sh
./scripts/start_server.sh
open http://localhost:8888/multiple_apps.html
```
Then open the "Input Event History" and "Text Edit" windows

## Tested
* Chromium
	* [x] drag-and-drop of files
	* Test both when a `TextEdit` is focused and when it is not:
	  * [x] `Event::Key`
	  * [x] `Event::Text`
	  * [x] copy-cut-paste
	  * [x] Wheel scroll
	* [x] `Event::PointerGone`
	* [x] Mouse drag
	* [x] Mouse click
	* [x] Mouse right-click
	* [x] Defocus all eframe canvas, and then start typing text
* [x] Firefox (all of the above)
* [x] Desktop Safari (all of the above)
* [x] Mobile Safari


## Future work (pre-existing issues)
* https://github.com/emilk/egui/issues/4723
* https://github.com/emilk/egui/issues/4724
* https://github.com/emilk/egui/issues/4725
* https://github.com/emilk/egui/issues/4726
2024-06-28 15:01:06 +02:00
..
ecolor Add `Color32::lerp_to_gamma` (#4627) 2024-06-06 15:41:10 +02:00
eframe eframe web: ignore keyboard events unless canvas has focus (#4718) 2024-06-28 15:01:06 +02:00
egui Add basic test for egui accesskit output. (#4716) 2024-06-28 13:03:31 +02:00
egui-wgpu Fix doclinks in egui-wgpu docs (#4677) 2024-06-19 11:26:26 +02:00
egui-winit Add `Key::Quote` (#4683) 2024-06-23 11:36:32 +02:00
egui_demo_app `eframe::Result` is now short for `eframe::Result<()>` (#4706) 2024-06-25 13:31:42 +02:00
egui_demo_lib Tweak two demos 2024-06-26 21:18:28 +02:00
egui_extras Sort feature flags in egui_extras 2024-06-27 14:29:59 +02:00
egui_glow Fix dragging of `custom_window_frame` example on Windows (#4656) 2024-06-19 16:19:41 +02:00
egui_plot plot zoom out max (#4695) 2024-06-26 16:34:34 +02:00
egui_web Fix typos (#2866) 2023-04-18 15:52:45 +02:00
emath Fix docstring 2024-06-26 09:00:11 +02:00
epaint Bug fix: ui opacity and gray-out not affecting strokes (#4581) 2024-05-29 22:37:55 +02:00