Metriche repository
- Star
- (23.592 star)
- Metriche merge PR
- (Merge medio 11g) (13 PR mergiate in 30 g)
Descrizione
@NickIliev commented on Wed Jul 03 2019
@Lelelo1 commented on Wed Jul 03 2019
Some of us would like to be able to subclass UIApplication so we can override the sendEvent method on ios. This is needed to detect user events that occur anywhere in the application like on the keyboard and without having to attach listeners everywhere - to each and every one of the controls.
Describe the solution you'd like
Just like we can implement UIApplicationDelegate:
class MyDelegate extends UIResponder implements UIApplicationDelegate {
public static ObjCProtocols = [UIApplicationDelegate];
touchesBeganWithEvent(touches: NSSet<UITouch>, event: _UIEvent): void {
console.log("touches began");
// will not be invoken when touch is on keybaord or is on a control
}
}
application.ios.delegate = MyDelegate;
...described here
It would be nice if we could:
class MyApplication extends UIApplication {
sendEvent(event: _UIEvent) {
console.log("event was: " + event);
}
}
application.ios.nativeApp = MyApplication; // <-- now throwing TypeError: Attempted to assign to readonly property.
before running app application.run({ moduleName: "app-root"});.
Describe alternatives you've considered
Add an additional property in application.ios that contains the UIApplication subclass to be used if given.
Additional context
From application.ios.js inside application module:
function _start(entry) {
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
started = true;
if (!iosApp.nativeApp) {
UIApplicationMain(0, null, null, iosApp && iosApp.delegate ? NSStringFromClass(iosApp.delegate) : NSStringFromClass(Responder));
}
The third argument should probably be NSStringFromClass(iosApp.nativeApp), and the if(!iosApp.nativeApp) check has to redesigned.
where principalClassName should be the name of the UIApplication subclass if given.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.