Comments (10)
@paescebu Thanks for your quickly reply.
I want the particular custom keyboard which is in editing mode to have this dismiss callback. After all, only one text field can be edited at a time.
from customkeyboardkit.
Perfect, very clear! Let's get to work then.
from customkeyboardkit.
@paescebu It doesn't seem to be working. I don't know if I'm missing something.
Code example:
let numberPad = CustomKeyboard.numberPad
numberPad.onEditingEnded = {
print("onEditingEnded") // Nothing happened here
}
textField.inputView = numberPad.keyboardInputView
static var numberPad: CustomKeyboard {
CustomKeyboardBuilder { textDocumentProxy, submit, playSystemFeedback in
return VStack {
// custom keyboard codes
}
.onEditingEndedCustomKeyboard {
print("onEditingEnded") // Nothing happened here
}
}
}
And I found textFieldDidEndEditing
is not called when I switch to other text field.
from customkeyboardkit.
@amoshsueh,
make sure you use the onEditingEndedCustomKeyboard
modifer the same way as the onSubmitCustomKeyboard
modifier in the README.md. When in SwiftUI (from outside the Keyboard) and after the use of the customKeyboard
modifier.
For UIKit i actually haven't tested it, yet and i guess to make it work there i have to change it up a bit :D
But ANYWAY, about my second thoughts:
I like to be inspired by the default keyboards and APIs from Apple (on iOS), like in Messages, Contacts etc.
- There we also don't have a dismiss button and therefore a programmatic dismiss API directly.
- Also for native keyboards we also don't have callbacks when the keyboard dismisses, but in order to achieve what you want, we'd use the
FocusState
property wrappers in SwiftUI or theUITextFieldDelegate
in UIKit for example and observe it's changes. I think that would be the best way also for CustomKeyboard and that should work out of the box for you. - To dismiss the keyboard programmatically, theres also no native API for it for the keyboards explicitly, but as well, we can set the focus State i assume, or call:
endEditing(true)
orresignFirstResponder()
on the textField in UIKit, or callUIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
from anywhere.
But I think FocusState is the way to go for both of your issues actually!
What do you think? Does it make sense what I'm saying or do you think this should actually be covered by the Keyboard, let me know! 😄
from customkeyboardkit.
I use my own custom text field created by UIViewRepresentable and apply onEditingEnded
but it's not working. Then I use SwiftUI's TextField and it's working perfectly. Maybe something wrong with my codes but it's fine.
I've been doing some thinking on my own, I should use this library in a different way. The below API of TextField already meets my needs:
public init<S>(_ title: S, text: Binding<String>, onEditingChanged: @escaping (Bool) -> Void) where S : StringProtocol
So I think maybe there is no need for onEditingEndedCustomKeyboard
. You can think about whether it is necessary to add this feature to the main branch.
I'm glad the discussion with you gave me some inspiration and thank you for being willing to share your thoughts with me.
Best wish.
from customkeyboardkit.
Hi @amoshsueh!
I think i understand what you mean! let me check if i can add something meaningful :)
Good idea!, I'll give it a go.
from customkeyboardkit.
Question:
What do you need in particular:
A callback when keybords dismiss in general? or when your particular custom keyboard dismisses?
Like, imagine you have multiple ones, would you want that all of those have separate callbacks?
from customkeyboardkit.
@paescebu By the way, is there any way to manually dismiss the custom keyboard?
from customkeyboardkit.
@amoshsueh could you check out the branchfeature/add-editing-ended-callback
and tell me if this is what you imagined?
it's used like:
SwiftUI: using a new modifier called: onEditingEndedCustomKeyboard(action:)
UIKit: assigning the CustomKeyboard the onEditingEnded
closure
About:
@paescebu By the way, is there any way to manually dismiss the custom keyboard?
No there is nothing yet, but I'll tell you how you can solve this otherwise :)
But i'm having second thoughts about this feature, i'll give you more insights after i got your feedback :)
from customkeyboardkit.
@amoshsueh
True! Completely forgot that TextField also has a closure for that already!
Awesome to hear that my thoughts inspired to think the need through :)
Have a great one!
from customkeyboardkit.
Related Issues (11)
- Package Dependencies HOT 3
- Use of "\n" instead of custom onSubmitCustomKeyboard block HOT 9
- SwiftUI: Conditionally switch between custom / system keyboard HOT 4
- SwiftUI GeometryReader not Working with .customKeyboard HOT 5
- Unable to pass conditionals or state variables in/out of the custom keyboard HOT 3
- Only calls one 'onSubmitCustomKeyboard' HOT 6
- Modifying state during view update HOT 3
- Missing important keys HOT 2
- SwiftUI-Introspect dependency outdate HOT 4
- Access textDocumentProxy from TextField code block HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from customkeyboardkit.