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

TextField not on edit mode at window opening #106

Open
jimmy-hypi opened this issue Sep 8, 2023 · 2 comments
Open

TextField not on edit mode at window opening #106

jimmy-hypi opened this issue Sep 8, 2023 · 2 comments

Comments

@jimmy-hypi
Copy link

jimmy-hypi commented Sep 8, 2023

I want to premise by saying that I just started using cacao so probably there's something silly I'm missing. I apologize in advance if that's the case.
The issue that I have is very simple: is there a way for a TextField to not be on edit mode right when the window finishes loading? Meaning: when the window is done loading and showing the TextField immediately awaits for input. Is there a way you can have it inactive until you click on it, as if "enter" is the first thing pressed? I can't figure out a way to make this work even though it sounds like a simple task :/

You can use the text_input.rs in the examples folder as an example.
Thanks

@jimmy-hypi jimmy-hypi changed the title TextField not focused at window opening TextField not on edit mode at window opening Sep 8, 2023
@ryanmcgrath
Copy link
Owner

You probably need to call [window makeFirstResponder:nil] (which we need to add on the Window in appkit) or you could try programmatically calling resignFirstResponder to hack around it for now.

e.g (pseudocode, you'll want to use the with_ accessor to get the native handle):

unsafe {
    let _: () = msg_send![native_handle, resignFirstResponder];
}

If that works, feel free to PR one (or both) to the library - they should be straightforward-ish to handle. I can't merge it until another PR is in, but this change shouldn't be interfering with it so it'd be nice to have lined up.

Hope it helps!

@jimmy-hypi
Copy link
Author

Unfortunately I'm afraid I'm not familiar enough with the framework to be able to make useful changes. In particular, I'm not sure where to call the code you suggested. To the best of my understanding, using resignFirstResponder the native handle should be the TextField handle right?
All the changes that I'm trying to apply are just ignored. But again, quite a trial and error as I have very little clue of what I'm doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants