@interface CallbackClass : NSObject
- (void) doSomething:(UIKeyCommand*)keycmd;
- (UIKeyCommand*) returnKeyCommand;
@end
@implementation CallbackClass
- (void) doSomething:(UIKeyCommand*)keycmd { NSLog(@"KEY CLICKED");
} -(UIKeyCommand*) returnKeyCommand { return [UIKeyCommand keyCommandWithInput:@"a" modifierFlags:0 action:@selector(doSomething:)]; } @end
void CppClass::bindKeyCommand() { CallbackClass* callbackClass = [[CallbackClass alloc] init];
[[UIApplication sharedApplication].keyWindow.rootViewController]
addKeyCommand:[callbackClass returnKeyCommand]];
}
This is objective-c code that is injected into QT application with C++ and Cmake. Responder chain after executing this code:
<QUIView> <QIOSDesktopManagerView> <QIOSViewController> key commands: <UIKeyCommand: 0x12....> -> Title: Action: doSomething: Input: @"a" ...
Even if this key command is present is in the responder chain i dont have any reaction on click on magic keyboard. When i do this in the pure objective-c but not with with QT, C++, Cmake project.
I Detect key input but only when i add my custom view controller do the subview of QIOSViewController, but then i cany click anything else on my application then.
I want to be able to detect key input or somehow inject a responder into responder chain and still being able to click things on my application.