Comments (1)
Thanks again for the detailed information on what happens and figuring out where the issue lies.
After looking into this I believed that you fix was the best option (although I was going to apply the fix directly in Widget::setFocused as the other location where canGainFocus is called doesn't require the recursive check). However, I accidentally fixed it in a completely different way.
I changed the order of operations in all widgets that override the setFocused function. Instead of letting TextArea set its m_caretVisible to true and then changing the focused state with the Widget::setFocused call, I decided to first call Widget::setFocused and only set m_caretVisible to true if m_focused actually became true (which wouldn't be the case with your canGainFocus patch). Doing the same in the Container class has a very surprising side-effect: failing to focus the container would unfocus its child widgets.
So the following now happens:
- You call TextArea::setFocused
- The text area tells its parent that is has been focused
- The container tries to focus itself but fails because it is disabled
- The container notices that the text area is focused and tells it to unfocus (at the end of Container::setFocused)
This means that edit box ends up unfocused, without changing how canGainFocus works. Hopefully the change I just made doesn't break a bunch of other situations though.
the caret will not show (I assume this is because its immediate parent no longer has a focused widget?
This is because Widget::setFocused won't set m_focused to true if canGainFocus returns false. The caret is only shown when both m_caretVisible and m_focused are true. Technically m_caretVisible is never supposed to be true when m_focused is false, but the value of m_caretVisible is simply ignored if m_focused is false so it still worked correctly even though m_caretVisible was wrong.
Which I think makes the most sense, even if it might cause confusion if one attempts to invoke setFocused(true) on an indirectly disabled widget.
It agree that not allowing the focus is the best solution. It's easy to explain why focusing doesn't work in that case, and it can be easily implemented.
I feel like it would be nice to be able to apply set focus once the Group is re-enabled, though I imagine this will be more complicated
Yeah, that would probably be too complex to implement, and the focusing code is already quite complicated.
from tgui.
Related Issues (20)
- Autocomplete support for EditBox HOT 2
- Can not input CJK words HOT 9
- Black background shown when changing window size HOT 4
- How to customize the window's title bar and frame HOT 2
- How to implement a polygon window HOT 2
- Hover style does not disappear when mouse moves out of the window HOT 6
- Add a 2d chart or rendering 3d data for TGUI? HOT 1
- Chinese support? HOT 5
- [ANNOUNCE] The TGUI now distributed via MSYS2 on Windows HOT 1
- CMake fails to install pkg-config files HOT 2
- On macOS, Input Method Editors(IME) behavior seems incorrect. HOT 6
- How to use SDL2/3 backend with cmake `FetchContent` HOT 2
- [Question] How to compile my first example of TGUI ? HOT 13
- [Bug] Dead radio button text HOT 3
- [Bug] Tabs state after disabled tab click HOT 2
- FileDialog documentation needs clarification and maybe working examples HOT 4
- Is there a C binding? HOT 12
- Raylib backend? HOT 15
- Cannot delete widgets inside of the gui-builder HOT 1
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 tgui.