-
Notifications
You must be signed in to change notification settings - Fork 313
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
Detect if RmlUi need use my inputs #124
Comments
Yes, this is already possible. The input functions |
Cursor events are not boolean, just keyboard |
Funny, i had same dilemma recently. It would be very useful. Events returning bools are ok, but they fall short of delivering. This would be extremely useful when combining multiple UI solutions, as well as handling game input. For example if we have a character jump function bound to a character, we would like character to not jump when we are typing text into UI. Also this would serve as a good hint for managing input focus between multiple |
I think a lot of the functionality can already be made in the application logic. Some things that work well for me:
See also I'm a bit worried that making some kind of built-in feature for such behavior would not be general enough to actually be useful. There will always be special cases for most applications. I don't think the library can do anything special in this regard, except perhaps make some common patterns easier to do. What do you think? |
Right, you are correct, and this is pretty much what i do now. My general beef with this approach is that there is no easy way to tell if a particular bool RmlUI::IsInputCapturedInternal() const
{
if (Rml::Element* element = rmlContext_->GetFocusElement())
{
const ea::string& tag = element->GetTagName();
return tag == "input" || tag == "textarea" || tag == "select";
}
return false;
} Which is not a very good approach. If i added a new element that takes keyboard focus i would need to update a completely unrelated spot, which will most likely be forgotten and result in a bug. If |
@rokups I don't actually think your solution is that bad, there are quite a limited number of relevant elements. And this approach is much more flexible than any library solution. @rafadsm |
Each element which reacts to keyboard input when focused should return true for WantCaptureKeyboard. Likewise each element that is currently active and reacts to mouse input should return true for WantCaptureMouse. Note that this would be completely opt-in, as elements would only provide a hint they want exclusive input, but it would be user's responsibility to act on it or not. In case of range element, say it is at the start of range and user presses left arrow. There is no place to move to the left and user may pass this input to other game systems for processing, and yet range element should return true as it does want keyboard input and is focused. User may do additional checking and pass input or not, depending on range element value and pressed key. Basically these hints would not introduce any limitations, only enable us to better manage input, or do nothing and keep current behavior, of we chose to. |
Okay I just had a look. The current behavior is that On the other hand Such a function also raises many questions. Should it return true for a button? What about a checker-box? Anything that can be tabbed? Anything that can be clicked? I don't know, I feel like a For mouse input on the other hand, I think we can come up with better solutions. But here as well I think a boolean return value should suffice. |
What you say makes sense. My only problem is that it does not work quite well with event-driven input systems (like mine). Main issue is that in such cases we need a strict order of event processing. Something like imgui -> [some other UI solution] -> [any number of Rml::Context] -> game input. If order is not guaranteed then bool result after event is processed is not very useful, especially if that order can change when some Rml::Context instance gets removed. This would happen if event subscribers are stored in a hashmap without order guarantee (like in my case). Basically bool result alone creates some non-obvious requirements for user's systems. With that said, i also think such ordered event processing is a good idea in general, and lack of it is a shortcoming of input processing system which i should correct on my end. I suppose my particular case where i have three different UI systems at play, with multiple contexts of one of them, is a very special case.. But we could certainly use a bool result from mouse processing events, including mouse movement. For example if we drag a slider knob and mouse goes out of window bounds, we still would like |
I understand your problem better now. Generally, I would say a well-defined, strict ordering for input handling is absolutely necessary. In terms of mouse input, I agree. What do you think about the following. Context functions
Elements with Anything we are missing then, or edge cases? I guess we'll have to just try and test it. |
That should be good. Cant think of anything why any of this would cause any issues. |
…te whether the mouse is interacting with any elements in the context. See #124.
Alright, I made a stab at it. Please let me know if any of this can be improved :) |
Would it be possible to detect if RmlUi needs to use my entries? Because I would like to prevent other components from being affected by the inputs if RmlUi uses them.
Thank you for your attention.
The text was updated successfully, but these errors were encountered: