Michel Bujardet Yesterday at 11:59 PM
I file this feature request with the sinking feeling that for iOS it is completely futile, and we are on our own to live in declare and workaround misery.
A related request to expose becameFirstResponder to do gotFocus has been in dungeon jails of oblivion since 2014
What do you need to use lost focus for? If the user closes the app (home button x2, swipe) I don’t believe you’ll get an event anyway. Can you not use TextChanged?
I know the dark side. I want to use my existing code and frankly would hate rewriting everything. That also would be a lot of pain and suffering onto itself…
That said, I am not in that of a pain. my wrapper contains isFirstResponder, all I have to do is use that in a custom class to have my own gotFocus and LostFocus. Which is my intention.
But I think of the numerous users who are not as fluent as me, and who indeed will live in pain. Pretty please, Xojo, have pity of the basic user.
LostFocus makes a lot of sense to format the TextField, or save its content.
Yes. You get a notification when your app is about to go into the background. You can use this very brief period to save the state of your app so it can restore properly - but it is not for save on quit type actions.
And there is no CancelClose, because iOS does not give your app that much power.
No need to use a delegate for these events. They exist as notifications too and can be caught by a UserNotificationCenter. Which is not part of Xojo iOS but many implementations exist.
Yes, its in iOSLib and OSXLib, working with the same code. You can pull an iosLibNotificationCenter (or OSXLib ) on your layout which is a custom subclass of NSNotificationCenter that does the handling of the Notification objects for you, which means it will deregister them automatically when it is closed. In its open event handler you can register all the notifications you would like to watch, like
(or whatever strings you find as Notification constants in Apples documentation.) Optionally you can pass the object to watch too, but I have not included a convenience wrapper for that yet.
It will then fire its Notification event when it receives a registered notification, forwarding this as an AppleNotification (NSNotification) object where you can read the name and userInfoDictionary from it. You could subclass this as well and build a AppNotificationCenter that fires different events like the ones listed by Dave. Or if you dont like the structure, take the main class AppleNotificationCenter and override the callback block that usually triggers the events.
Both libraries have demo windows/views with a NotificationCenter.