summaryrefslogtreecommitdiffstats
path: root/DOCS/client_api_examples
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2015-02-28 14:50:06 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2015-02-28 14:55:32 +0100
commit03a69bac95ce4e15016138104cd198a6a60c38cd (patch)
treea1be2c97e53e2320c6b126786a14545a19634825 /DOCS/client_api_examples
parent721e430cd2da16e0802781171a3cedb3849eec24 (diff)
downloadmpv-03a69bac95ce4e15016138104cd198a6a60c38cd.tar.bz2
mpv-03a69bac95ce4e15016138104cd198a6a60c38cd.tar.xz
cocoa: remove the setNextKeyView hack
Just use makeFirstResponder on the mpv events view from client code if you need the built in keyboard events (this is easier for dealing with view nesting).
Diffstat (limited to 'DOCS/client_api_examples')
-rw-r--r--DOCS/client_api_examples/cocoa/cocoabasic.m16
1 files changed, 14 insertions, 2 deletions
diff --git a/DOCS/client_api_examples/cocoa/cocoabasic.m b/DOCS/client_api_examples/cocoa/cocoabasic.m
index 80656815ca..f2d9059afe 100644
--- a/DOCS/client_api_examples/cocoa/cocoabasic.m
+++ b/DOCS/client_api_examples/cocoa/cocoabasic.m
@@ -33,6 +33,7 @@ static inline void check_error(int status)
mpv_handle *mpv;
dispatch_queue_t queue;
NSWindow *w;
+ NSView *wrapper;
}
@end
@@ -55,6 +56,12 @@ static void wakeup(void *);
[self->w makeMainWindow];
[self->w makeKeyAndOrderFront:nil];
+ NSRect frame = [[self->w contentView] bounds];
+ self->wrapper = [[NSView alloc] initWithFrame:frame];
+ [self->wrapper setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
+ [[self->w contentView] addSubview:self->wrapper];
+ [self->wrapper release];
+
NSMenu *m = [[NSMenu alloc] initWithTitle:@"AMainMenu"];
NSMenuItem *item = [m addItemWithTitle:@"Apple" action:nil keyEquivalent:@""];
NSMenu *sm = [[NSMenu alloc] initWithTitle:@"Apple"];
@@ -95,7 +102,7 @@ static void wakeup(void *);
exit(1);
}
- int64_t wid = (intptr_t) [self->w contentView];
+ int64_t wid = (intptr_t) self->wrapper;
check_error(mpv_set_option(mpv, "wid", MPV_FORMAT_INT64, &wid));
// Maybe set some options here, like default key bindings.
@@ -138,7 +145,12 @@ static void wakeup(void *);
case MPV_EVENT_VIDEO_RECONFIG: {
dispatch_async(dispatch_get_main_queue(), ^{
- [self->w selectNextKeyView:nil];
+ NSArray *subviews = [self->wrapper subviews];
+ if ([subviews count] > 0) {
+ // mpv's events view
+ NSView *eview = [self->wrapper subviews][0];
+ [self->w makeFirstResponder:eview];
+ }
});
}