File: autokeyviewchain.m

package info (click to toggle)
lusernet.app 0.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 828 kB
  • sloc: objc: 8,495; makefile: 22
file content (83 lines) | stat: -rw-r--r-- 1,573 bytes parent folder | download | duplicates (6)
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
/*
copyright 2002 Alexander Malmberg <alexander@malmberg.org>
*/

#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