Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input not focused when selecting text #4563

Open
jprochazk opened this issue May 28, 2024 · 0 comments
Open

Input not focused when selecting text #4563

jprochazk opened this issue May 28, 2024 · 0 comments
Labels
web Related to running Egui on the web

Comments

@jprochazk
Copy link
Collaborator

Repro:

  1. Open Demos -> Widget Gallery on the web demo
  2. Run setInterval(() => console.log(document.activeElement), 1000) in a devtools console
  3. Type something into the first text field
  4. Click somewhere outside of the text field to blur it
  5. Select the text by dragging over it - make sure the text field is blurred!

Expected behavior: runner.mutable_text_under_cursor is set to true, causing the <input> element to be the document.activeElement
Actual behavior: runner.mutable_text_under_cursor is false, and document.activeElement == document.body

@jprochazk jprochazk mentioned this issue May 28, 2024
5 tasks
@jprochazk jprochazk added the web Related to running Egui on the web label May 28, 2024
emilk added a commit that referenced this issue Jun 28, 2024
* Fixes rerun-io/rerun#6638
* Related? #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)
* #4723
* #4724
* #4725
* #4726
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
* Fixes rerun-io/rerun#6638
* Related? emilk#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)
* emilk#4723
* emilk#4724
* emilk#4725
* emilk#4726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web Related to running Egui on the web
Projects
None yet
Development

No branches or pull requests

1 participant