Comments (15)
I think I will try to implement this unless it's too complicated. Any pointers before I start?
from egui.
Cool. Thanks! I agree with your thoughts on focus above, I will start to hack around and see where I end up and ping you on discord if needed :)
from egui.
I'm gonna start working on this
from egui.
@emoon no worries, I know the feeling :)
Please prioritize real life to egui - I sure do!
from egui.
Switching between input fields with tab and shift-tab has now been implemented on master
. Pressing enter in a singleline text edit box now sets the kb_focus_lost
flag in the Response
object, so you can use that.
from egui.
Tested this today and it seems that I wonder if it would be possible to support for all widgets (such the way it works in a regular gui) and not just for input fields?
from egui.
That would be nice yes, but it is not very high on my priority list right now
from egui.
Wow, that would be great!
The feature that handles focus of TextEdit
:s is called "kb_focus".
I think first of all, let's split this into two tasks:
A) tab also moves kb_focus to buttons, checkboxes, sliders etc
B) gamepad support for moving kb_focus up/down/left/right
Let's start with A, and postpone B until A is done.
First we have some design problems:
When clicking a TextEdit
we get a cursor in it, and it is obvious it has kb_focus. If we then press tab and move focus to a checkbox, how do we indicate it has focus? We need a uniform language for focus. To start, the easiest would probably be some sort of thing colored rectangle around the widget with kb_focus (including TextEdit
:s). That or changing its fg_color. This accent could perhaps become confusing when it comes to SelectableLabel
which uses color to indicate "this is selected".
We can give kb_focus to a TextEdit by clicking it. Can we give kb_focus to a checkbox or slider by clicking it? I strongly vote no on this one, as it would give add some weird accent to the last button you pressed all the time. Instead I propose that the only way to give kb_focus to a button is by using tab/shift-tab.
What happens when a slider has kb_focus? Arrows to move the slider one pixel? Enter to edit the value?
How do we toggle/click buttons? Enter? Space?
As for the implementation:
Look at TextEdit
. It uses interested_in_kb_focus
to communicate that it want tab to select it. It asks if it has focus with has_kb_focus
. So most buttons would just need to call interested_in_kb_focus
and then ask has_kb_focus
. It should be pretty straight-forward.
For the accent: whatever style you go with, make sure it is stored in struct Visuals
Good luck!
If you want to discuss this in more detail, you can find me in the Egui discord channel at https://discord.gg/vY8ZGS292W
from egui.
Some initial testing with checkbox (ignore the red colors for the radiobuttons, it was me playing around) :)
from egui.
Any new progress on this? It's something I need too, so I may take a crack at it.
from egui.
I haven't got around to do it 😞 if you want to take a stab at it that would be great!
from egui.
from egui.
@ndarilek keyboard focus is indeed part of egui::Memory
, in particular these functions: https://github.com/emilk/egui/blob/master/egui/src/memory.rs#L202-L244
Basically what is needed for this issue is that all interactive widgets call interested_in_kb_focus
, and then checks has_kb_focus
to see if they have kb_focus, and if so paint a rectangle around them and maybe response to space/return (e.g. to press the selected button). If you are interested in working on this I suggest you check out how text_edit.rs
are calling the kb_focus
methods. Since a lot of widgets will do similar things (request focus, check focus, paint frame when selected, ...) it would make sense to create some helper functions for it.
from egui.
I added the accessibility
and high priority
labels since this is crucial for the accessibility story (#167)
from egui.
Awesome! Sorry I didn't manage to get around to do it, but real life has gotten a bit in the way :/
from egui.
Related Issues (20)
- `set_clip_rect` draws over `SidePanel` when children widgets exceed the available space HOT 2
- FontBook demo doesn't scale HOT 4
- Add `Response::context_menu_with_id` API HOT 4
- Ui::dnd_drop_zone() swallows the inner Response HOT 2
- TextAgent assumes canvas is aligned to the top HOT 4
- [eframe native-windows] Entire program crashes when eframe viewport is resized from a corner HOT 12
- Items are not clickable when inside a row of a `TableBuilder` HOT 2
- Ctrl+X, C, V events get cut out HOT 3
- Remove `id_source` parameter for ui.indent HOT 1
- error: no such command: `cranky` HOT 2
- The program screen flickers (shakes) when resizing.
- Suggest enabling the Viewport to be built on a user-specified monitor at launch time
- Issue with number key mapping part #2
- Universal clipboard shortcuts (`Ctrl`+`C`/`V`/`X`) don't work with non-Latin keyboard layouts
- Display parent viewport id Issues
- rfd 0.14 conflicts with eframe on macOS HOT 6
- error: implementation of `Deserialize` is not general enough HOT 1
- ViewportCommand::Visible(false) doesn't appear to do anything
- Immediate viewport would crash with ViewportBuilder settings `fullscreen` + `transparent` + `always_on_top` HOT 1
- Context menus are not very flexible.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from egui.