-
Notifications
You must be signed in to change notification settings - Fork 298
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
Provide Ui
methods that allow for user input to be captured externally.
#613
Comments
Hmm... this was a bit harder than anticipated. Haven't thought this through yet, so just posting ideas:
|
What if we build in the logic of focusing events on the background? Could
|
I am starting to believe that your idea is better. We could implement it, then try it out and see if it works. If it doesn't, then we'll try something else. |
It sounds like the essential question here is, what owns the decision of whether a particular event applies to a given widget? Right now, each widget has visibility to all events and the widget decides whether or not keyboard/mouse input applies to it. Do I understand that correctly? Going forward, think it makes sense that we have clarity on what owns that decision. If the Widget owns the decision as to which key/mouse events apply to it, then it doesn't seem to make sense to call On the other hand, we could have the Ui determine which keyboard/mouse events apply to which widgets. In this case, it would seem to make sense to just call something like I think either approach is valid, but it seems like currently, it's really caught in the middle. I've been thinking a lot about this because of the difficulties in coming up with a clean solution for #606 . Any thoughts on pros/cons of either approach? Or do you think I'm just barking up the wrong tree with this question? |
Hey @psFried, you're not barking up the wrong tree at all! Input like this is always highly appreciated 😸 Just to clarify, this issue proposes to add one extra way of capturing input - the At the moment conrod is designed so that only one widget may capture either kind of user input at a time. This widget is tracked within the Side note: A user should never need to capture more than one widget at once, as they can only click one thing at a time or enter text into one thing at a time. If they do come across an instance where multiple widgets need to be captured (let's say typing into multiple The Seeing as we may only have a single capturer of a kind of input at a time, it doesn't make sense for a widget to be able to immediately steal input whenever it wants, especially if it is already captured by another widget. Thus we want to make sure that although a widget can make a request to capture input, the Sorry for the rambling, hopefully this clarifies things a bit - let me know if there are still issues! I'll try and add this stuff to the guide #505 when it happens one day heh. Thanks a lot for putting some thought into tab switching btw, would certainly be nice to have :) |
@mitchmindtree Thanks, that does clarify things. I think overall, it makes sense to me that each Widget should not even receive Input if it is not capturing. The Ui could determine which Widget should begin capturing whenever the mouse is clicked. That would save every Widget from having to do the same check to see if it should ask the Ui to be given focus. Seems like that would simplify the issue of adding methods to ui to change what is capturing keyboard/mouse, and I think it would also simplify adding the ability to tab between input fields. |
This would be useful when conrod is used alongside other non-conrod user interface code (i.e within turbine).
To achieve this, we could simply add a
CaptureSource
enum, i.e.We could use this within the
Capturing
enum'sCaptured
variant in place of thewidget::Index
.I imagine the methods would look something like this:
When
capture_mouse
orcapture_keyboard
are called, theUi
would force itsmaybe_captured_mouse/keyboard
field toSome(Captured(External))
whether or not the user input was captured or not. The methods return abool
, indicating whether or not the user input was already captured.We could also add
try_capture_mouse
andtry_capture_keyboard
methods which would only capture the input if they were not already captured, returning abool
indicating whether or not the user input was successfully captured.The text was updated successfully, but these errors were encountered: