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
Soft keyboard input for iOS #3571
base: master
Are you sure you want to change the base?
Soft keyboard input for iOS #3571
Conversation
src/platform/ios.rs
Outdated
@@ -100,6 +100,7 @@ pub trait WindowExtIOS { | |||
/// | |||
/// The default is to not recognize gestures. | |||
fn recognize_rotation_gesture(&self, should_recognize: bool); | |||
fn set_keyboard_visible(&self, visible: bool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have set_ime_allowed
, so wire to it for now.
324d220
to
78bac6b
Compare
The WinitTextViewDelegate must remain in memory or it will be collected on the objective-c side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added a few comments wrt. objc2
stuff.
Regarding the implementation, I'm unsure if this is the right approach? Adding a hidden view like this seems like it could get into a lot of trouble with event focus?
There's no other way to control the software keyboard?
(I suspect this will be easier to solve after something like #3506, but I'd be fine with this until then).
src/platform_impl/ios/text_field.rs
Outdated
// These are methods from UIResponder | ||
#[method(becomeFirstResponder)] | ||
pub fn focus(&self) -> bool; | ||
|
||
#[method(resignFirstResponder)] | ||
pub fn unfocus(&self) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be moved to an extern_methods!
on UIResponder
.
fn window(&self) -> Option<Id<WinitUIWindow>> { | ||
unsafe { msg_send_id![self, window] } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather have this on UIView
and return UIWindow
, and then when the WinitUIWindow
is needed, you'd use the method on UIView
, but with an Id::cast
to turn it into WinitUIWindow
.
} | ||
|
||
declare_class!( | ||
pub(crate) struct WinitTextField; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect you don't need to subclass UITextField
, i.e. this class is unnecessary as long as you make sure to store the WinitTextFieldDelegate
somewhere else (e.g. on WinitView
, as done currently).
Co-authored-by: Mads Marquart <mads@marquart.dk>
Co-authored-by: Mads Marquart <mads@marquart.dk>
Co-authored-by: Mads Marquart <mads@marquart.dk>
After some research and thought, I don't think so but I'm not sure what the least-bad-way to do it is. I wrote about this in a chat but felt like it needed to on this issue. I decided to look at how Flutter does it and how SwiftUI probably does it. For Flutter: I created a simple flutter app with just a For SwiftUI, I created a simple view with a I'd look into how xamrin does text input but given how old it is, I'm pretty sure it's using a |
CHANGELOG.md
if knowledge of this change could be valuable to usersRelated to #2260 and #1823.