Closed SPMen closed 1 year ago
Hey! Thanks for your kind words! And your very detailed lookinto it already! Very good find! I agree that it should not work like this!
Im pretty confident it has to do with the fact that we define one static keyboard in my example. And every assignment of the "onSubmit" closure reassigns it and therefore you lose the previous closure.
I think to fix this I have to redesign this API so that every textfield can have its own keyboard instance with its own onSubmit closure.
Will get to work as soon as possible! :)
Hey @SPMen, Good news, I think i managed to find a solution that keeps the API the same, just how the CustomKeyboard needs to be declared changes slightly (a static computed property (or method) instead of a static stored property), see the examples in the adjusted README :) Can you try out the implementation of the linked branch and tell me if it fixes the issue for you? I tested it on my side and it seems to work fine now.
I will merge upon your approval if its fixed for you :)
Kind regards Pascal
Hello Pascal,
Wow...yes, this works great!!! I tried the changes on the test code I posted and on my own project. It worked perfectly for both.
Thank you for sharing CustomKeyboardKit...it really is so helpful, so simple, and a gift to those of us who use it (and aren't quite as impressive in programming as you are). You are kind to share!
Take care, Stephen
Omg thank you for your kind words!
But Kudos to you! Your first analysis and great systematic feedback helped me to nail down the issue efficiently!
I will merge it to master directly so that you'll have the changes when you directly fetch the Swift Package next time :-)
Have a great weekend! Pascal
@paescebu anywhere I can buy you a coffee or show some support?
@paescebu anywhere I can buy you a coffee or show some support?
@bwalton haha it's really not necessary to pay me anything. But i quickly and dirty set up a PayPal donation link and a buy me a coffee link. It's in the updated README.
Thanks for appreciating my tiny package anyway!
This is such a help....thank you so much for posting it. You're absolutely right to say it is the easiest way to add a custom keyboard to SwiftUI.
I've been having one issue: only one
onSubmitCustomKeyboard
is called, even if I have multiple instances with a few different text fields. I thought at first it might be something in my code, so here's what I did to check: I started a new project in Xcode, installed the package, and copied the code of your sampleyesnt
keyboard. Then I only slightly modified your sample implementation:When run, only the first
onSubmitCustomKeyboard
is ever called ("Textfield #1 submit"), even whensubmit?()
is called in Textfield #2 or Textfield #3.Is that how it is supposed to work? In my own actual project, for some reason it is oddly calling the third instance of
onSubmitCustomKeyboard
every time, and I can't make sense of why.