mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 21:30:37 +00:00
Key binding patch by Chris Farber <chris@chrisfarber.net>.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25724 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2d0d6f2880
commit
fa44004ac5
8 changed files with 881 additions and 10 deletions
|
@ -41,6 +41,7 @@
|
|||
#include <Foundation/NSCalendarDate.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#include <Foundation/NSKeyedArchiver.h>
|
||||
#include <Foundation/NSKeyValueObserving.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSThread.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
|
@ -62,6 +63,7 @@
|
|||
#include "AppKit/NSClipView.h"
|
||||
#include "AppKit/NSFont.h"
|
||||
#include "AppKit/NSGraphics.h"
|
||||
#include "AppKit/NSKeyValueBinding.h"
|
||||
#include "AppKit/NSMenu.h"
|
||||
#include "AppKit/NSPasteboard.h"
|
||||
#include "AppKit/NSPrintInfo.h"
|
||||
|
@ -74,6 +76,7 @@
|
|||
#include "GNUstepGUI/GSDisplayServer.h"
|
||||
#include "GNUstepGUI/GSTrackingRect.h"
|
||||
#include "GSToolTips.h"
|
||||
#include "GSBindingHelpers.h"
|
||||
|
||||
/*
|
||||
* We need a fast array that can store objects without retain/release ...
|
||||
|
@ -431,6 +434,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
rectClass = [GSTrackingRect class];
|
||||
NSDebugLLog(@"NSView", @"Initialize NSView class\n");
|
||||
[self setVersion: 1];
|
||||
|
||||
// expose bindings
|
||||
[self exposeBinding: NSToolTipBinding];
|
||||
[self exposeBinding: NSHiddenBinding];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -504,6 +511,8 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
NSView *tmp;
|
||||
unsigned count;
|
||||
|
||||
GSBindingUnbindAll(self);
|
||||
|
||||
while ([_sub_views count] > 0)
|
||||
{
|
||||
[[_sub_views lastObject] removeFromSuperviewWithoutNeedingDisplay];
|
||||
|
@ -4718,5 +4727,70 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void) bind: (NSString *)binding
|
||||
toObject: (id)object
|
||||
withKeyPath: (NSString *)keyPath
|
||||
options: (NSDictionary *)options
|
||||
{
|
||||
NSMutableDictionary *bindings;
|
||||
NSDictionary *info;
|
||||
BOOL hidden;
|
||||
|
||||
if ([binding hasPrefix: NSHiddenBinding])
|
||||
{
|
||||
[self unbind: binding];
|
||||
|
||||
[object addObserver: self
|
||||
forKeyPath: keyPath
|
||||
options: 0
|
||||
context: NSHiddenBinding];
|
||||
info = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
object, NSObservedObjectKey,
|
||||
keyPath, NSObservedKeyPathKey,
|
||||
options, NSOptionsKey,
|
||||
nil];
|
||||
GSBindingLock();
|
||||
bindings = GSBindingListForObject(self);
|
||||
[bindings setValue: info forKey: binding];
|
||||
hidden = GSBindingResolveMultipleValueBool(NSHiddenBinding, bindings,
|
||||
GSBindingOperationOr);
|
||||
GSBindingReleaseLock();
|
||||
[self setHidden: hidden];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super bind: binding
|
||||
toObject: object
|
||||
withKeyPath: keyPath
|
||||
options: options];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) observeValueForKeyPath: (NSString *)keyPath
|
||||
ofObject: (id)object
|
||||
change: (NSDictionary *)change
|
||||
context: (void *)context
|
||||
{
|
||||
BOOL hidden;
|
||||
NSDictionary * bindings;
|
||||
|
||||
if (context == NSHiddenBinding)
|
||||
{
|
||||
GSBindingLock();
|
||||
bindings = GSBindingListForObject(self);
|
||||
hidden = GSBindingResolveMultipleValueBool(NSHiddenBinding, bindings,
|
||||
GSBindingOperationOr);
|
||||
GSBindingReleaseLock();
|
||||
[self setHidden: hidden];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super observeValueForKeyPath: keyPath
|
||||
ofObject: object
|
||||
change: change
|
||||
context: context];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue