mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 18:10:38 +00:00
Moved focus handling to graphics context
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3859 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7efd28bd8b
commit
db56ad4a9d
4 changed files with 90 additions and 91 deletions
|
@ -89,74 +89,12 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
|||
}
|
||||
|
||||
/*
|
||||
* return the view at the top of thread's focus stack
|
||||
* return the view at the top of graphics contexts stack
|
||||
* or nil if none is focused
|
||||
*/
|
||||
+ (NSView*) focusView
|
||||
{
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
NSMutableArray *stack = [dict objectForKey: viewThreadKey];
|
||||
NSView *current_view = nil;
|
||||
|
||||
if (stack)
|
||||
{
|
||||
unsigned count = [stack count];
|
||||
|
||||
if (count > 0)
|
||||
current_view = [stack objectAtIndex: --count];
|
||||
}
|
||||
|
||||
return current_view;
|
||||
}
|
||||
|
||||
|
||||
+ (void) pushFocusView: (NSView*)focusView
|
||||
{
|
||||
if (focusView)
|
||||
{
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
NSMutableArray *stack = [dict objectForKey: viewThreadKey];
|
||||
|
||||
if (stack == nil)
|
||||
{
|
||||
stack = [[NSMutableArray alloc] initWithCapacity: 4];
|
||||
[dict setObject: stack forKey: viewThreadKey];
|
||||
[stack release];
|
||||
}
|
||||
[stack addObject: focusView];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Attempt to push a 'nil' focus view on to stack."];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove the top focusView for the current thread from the stack
|
||||
* and return the new focusView (or nil if the stack is now empty).
|
||||
*/
|
||||
+ (NSView*) popFocusView
|
||||
{
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
NSMutableArray *stack = [dict objectForKey: viewThreadKey];
|
||||
NSView *v = nil;
|
||||
|
||||
if (stack)
|
||||
{
|
||||
unsigned count = [stack count];
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
[stack removeObjectAtIndex: --count];
|
||||
}
|
||||
if (count > 0)
|
||||
{
|
||||
v = [stack objectAtIndex: --count];
|
||||
}
|
||||
}
|
||||
return v;
|
||||
return [[NSGraphicsContext currentContext] focusView];
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue