Skip to content
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

Allow open detection #27

Merged
merged 2 commits into from
May 24, 2024
Merged

Conversation

Robert-M-Lucas
Copy link
Contributor

Objective

Currently, there appears to be no way to tell if the console is open. This is an almost required feature for a console as without it you cannot block inputs while using the console or control how the mouse behaves when the console is open.

Solution

  • Exposed the ConsoleUiState struct (keeping the fields as only crate public)
  • Exposed a function that returns whether the console is currently open

Imagined usage

(with the console only conditionally included in the project)

fn keyboard_update(
    ...,
    #[cfg(debug_assertions)]
    console: Res<ConsoleUiState>
) {
    #[cfg(debug_assertions)]
    if console.open() {
        return;
    }

    ...
}

I can also see this being useful for locking and unlocking the mouse based on whether the console is visible.

Other

There also appears to be a text_focus field however this appears to not be updated while the console is
presented. In the future, it'd be nice to have an text_focused() method so that an open console only blocks
input when the text field is selected.

Copy link
Owner

@doonv doonv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@doonv doonv added C-Enhancement New feature or request A-UI This is related to the User Interface labels May 24, 2024
@doonv doonv merged commit 3814f05 into doonv:master May 24, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI This is related to the User Interface C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants