Skip to content

Provide Ui methods that allow for user input to be captured externally. #613

@mitchmindtree

Description

@mitchmindtree

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.

/// Indicates where the user input is being captured from.
pub enum CaptureSource {
    /// The user input is captured by external means.
    External,
    /// The user input is captured by an internal widget.
    Internal(widget::Index),
}

We could use this within the Capturing enum's Captured variant in place of the widget::Index.

I imagine the methods would look something like this:

ui.capture_mouse();
ui.uncapture_mouse();
ui.capture_keyboard();
ui.uncapture_keyboard();

When capture_mouse or capture_keyboard are called, the Ui would force its maybe_captured_mouse/keyboard field to Some(Captured(External)) whether or not the user input was captured or not. The methods return a bool, indicating whether or not the user input was already captured.

We could also add try_capture_mouse and try_capture_keyboard methods which would only capture the input if they were not already captured, returning a bool indicating whether or not the user input was successfully captured.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions