-
Notifications
You must be signed in to change notification settings - Fork 1
/
autokeyviewchain.m
88 lines (65 loc) · 1.81 KB
/
autokeyviewchain.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
copyright 2002 Alexander Malmberg <[email protected]>
This file is a part of Terminal.app. Terminal.app is free software; you
can redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation; version 2
of the License. See COPYING or main.m for more information.
*/
#include <Foundation/NSObject.h>
#include <AppKit/NSView.h>
#include <AppKit/NSWindow.h>
#include "autokeyviewchain.h"
@implementation NSWindow (autokeyviewchain)
-(void) autoSetupKeyViewChain
{
NSView *v=[self contentView];
[self setInitialFirstResponder: [v autoSetupKeyViewChain: nil]];
/* {
NSView *v=[self initialFirstResponder];
printf("window %p initial=%p\n",self,v);
for (;v;v=[v nextKeyView])
{
printf(" '%@'\n",v);
}
}*/
}
@end
/* just to get rid of warnings */
#include <AppKit/NSScrollView.h>
#include <AppKit/NSClipView.h>
@implementation NSView (autokeyviewchain)
-(NSView *) autoSetupKeyViewChain: (NSView *) next
{
if ([self acceptsFirstResponder])
{
[self setNextKeyView: next];
next=self;
}
/* use NSScrollView to get rid of warning */
if ([self respondsToSelector: @selector(documentView)])
next=[[(NSScrollView *)self documentView] autoSetupKeyViewChain: next];
else if ([self respondsToSelector: @selector(contentView)])
next=[[(NSScrollView *)self contentView] autoSetupKeyViewChain: next];
return next;
}
@end
#include <GNUstepGUI/GSTable.h>
@implementation GSTable (autokeyviewchain)
-(NSView *) autoSetupKeyViewChain: (NSView *) next
{
int i,j;
NSView *v;
for (i=0;i<_numberOfRows;i++)
{
for (j=_numberOfColumns-1;j>=0;j--)
{
if (_jails[i*_numberOfColumns+j])
{
v=[[(NSView *)_jails[i*_numberOfColumns+j] subviews] objectAtIndex: 0];
next=[v autoSetupKeyViewChain: next];
}
}
}
return next;
}
@end