Skip to content

Instantly share code, notes, and snippets.

@saikyun
Created April 13, 2021 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saikyun/9e763b125640d89ccc34ef62b39df918 to your computer and use it in GitHub Desktop.
Save saikyun/9e763b125640d89ccc34ef62b39df918 to your computer and use it in GitHub Desktop.
41.09 How to handle focus
Kinds of focus
- Mouse clicks
- Hover
- Drag
- Keyboard handling
- (Re)rendering
How to detect focus
- Mouse click / hover / drag
- “global” — assuming a single mouse
- Keyboard handling
- local, depends on current focus
I.e. mouse “events” should probably be handled globally, then “passed” to the correct place
Keyboard focus is different, though could perhaps also be globally handled
(Re)rendering is local
Ways to solve
- Mouse focus
- When mouse is colliding with an area, “a hitbox” of a ui element, that thing is focused
- Keyboard focus
- Actions trigger focusing for keyboard events, e.g.
- Clicking an element
- Using ctrl+tab (or similar)
- Possible M+e / M+g to switch between editor and game
- (Re)rendering
- This should be local, i.e. if the thing is “active” it should be rendered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment