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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
|
/** <title>NSMenuItem</title>
<abstract>The menu cell class.</abstract>
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: May 1997
Author: David Lazaro Saz <khelekir@encomix.es>
Date: Sep 1999
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import "config.h"
#import <Foundation/NSAttributedString.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
#import <Foundation/NSUserDefaults.h>
#import "AppKit/NSCell.h"
#import "AppKit/NSEvent.h"
#import "AppKit/NSImage.h"
#import "AppKit/NSKeyValueBinding.h"
#import "AppKit/NSMenuItem.h"
#import "AppKit/NSMenu.h"
#import "GSBindingHelpers.h"
static BOOL usesUserKeyEquivalents = NO;
static Class imageClass;
@interface GSMenuSeparator : NSMenuItem
@end
@implementation GSMenuSeparator
- (Class) classForCoder
{
return [NSMenuItem class];
}
- (id) init
{
self = [super initWithTitle: @"-----------"
action: NULL
keyEquivalent: @""];
if (self == nil)
return nil;
_enabled = NO;
_changesState = NO;
return self;
}
- (BOOL) isSeparatorItem
{
return YES;
}
// FIXME: We need a lot of methods to switch off changes for a separator
@end
@implementation NSMenuItem
+ (void) initialize
{
if (self == [NSMenuItem class])
{
[self setVersion: 4];
imageClass = [NSImage class];
[self exposeBinding: NSEnabledBinding];
}
}
+ (void) setUsesUserKeyEquivalents: (BOOL)flag
{
usesUserKeyEquivalents = flag;
}
+ (BOOL) usesUserKeyEquivalents
{
return usesUserKeyEquivalents;
}
+ (id <NSMenuItem>) separatorItem
{
return AUTORELEASE([GSMenuSeparator new]);
}
- (id) init
{
return [self initWithTitle: @""
action: NULL
keyEquivalent: @""];
}
- (void) dealloc
{
// Remove all key value bindings for this view.
[GSKeyValueBinding unbindAllForObject: self];
TEST_RELEASE(_title);
TEST_RELEASE(_keyEquivalent);
TEST_RELEASE(_image);
TEST_RELEASE(_onStateImage);
TEST_RELEASE(_offStateImage);
TEST_RELEASE(_mixedStateImage);
TEST_RELEASE(_submenu);
TEST_RELEASE(_representedObject);
TEST_RELEASE(_toolTip);
[super dealloc];
}
- (id) initWithTitle: (NSString*)aString
action: (SEL)aSelector
keyEquivalent: (NSString*)charCode
{
self = [super init];
if (self == nil)
return nil;
//_menu = nil;
[self setKeyEquivalent: charCode];
_keyEquivalentModifierMask = NSCommandKeyMask;
[self setTitle: aString]; // do this AFTER setKeyEquivalent: in case NSUserKeyEquivalents is defined
_mnemonicLocation = 255; // No mnemonic
_state = NSOffState;
_enabled = YES;
//_image = nil;
// Set the images according to the spec. On: check mark; off: dash.
[self setOnStateImage: [imageClass imageNamed: @"NSMenuCheckmark"]];
[self setMixedStateImage: [imageClass imageNamed: @"NSMenuMixedState"]];
//_offStateImage = nil;
//_target = nil;
_action = aSelector;
//_changesState = NO;
return self;
}
- (void) _updateKeyEquivalent
{
// Update keyEquivalent based on any entries in NSUserKeyEquivalents in the defaults database
// TODO: also check in other defaults domains, to allow NSUserKeyEquivalents dictionaries
// in different domains to provide overrides of different menu items.
NSString *userKeyEquivalent = [(NSDictionary*)[[NSUserDefaults standardUserDefaults]
objectForKey: @"NSUserKeyEquivalents"]
objectForKey: _title];
if (userKeyEquivalent)
{
// check for leading symbols representing modifier flags: @, ~, $, ^
NSUInteger modifierMask = 0;
while ([userKeyEquivalent length] > 1)
{
if ([userKeyEquivalent hasPrefix:@"@"])
{
modifierMask |= NSCommandKeyMask;
userKeyEquivalent = [userKeyEquivalent substringFromIndex:1];
}
else if ([userKeyEquivalent hasPrefix:@"~"])
{
modifierMask |= NSAlternateKeyMask;
userKeyEquivalent = [userKeyEquivalent substringFromIndex:1];
}
else if ([userKeyEquivalent hasPrefix:@"$"])
{
modifierMask |= NSShiftKeyMask;
userKeyEquivalent = [userKeyEquivalent substringFromIndex:1];
}
else if ([userKeyEquivalent hasPrefix:@"^"])
{
modifierMask |= NSControlKeyMask;
userKeyEquivalent = [userKeyEquivalent substringFromIndex:1];
}
else
{
break;
}
}
[self setKeyEquivalent:userKeyEquivalent];
[self setKeyEquivalentModifierMask:modifierMask];
}
}
- (void) setMenu: (NSMenu*)menu
{
/* The menu is retaining us. Do not retain it. */
_menu = menu;
if (_submenu != nil)
{
[_submenu setSupermenu: menu];
[self setTarget: _menu];
}
}
- (NSMenu*) menu
{
return _menu;
}
- (BOOL) hasSubmenu
{
return (_submenu == nil) ? NO : YES;
}
- (void) setSubmenu: (NSMenu*)submenu
{
if (submenu == _submenu)
return; // no change
if ([submenu supermenu] != nil)
{
[NSException raise: NSInvalidArgumentException
format: @"submenu (%@) already has supermenu (%@)",
[submenu title], [[submenu supermenu] title]];
}
ASSIGN(_submenu, submenu);
if (submenu != nil)
{
[submenu setSupermenu: _menu];
[submenu setTitle: _title];
}
[self setTarget: _menu];
[self setAction: @selector(submenuAction:)];
[_menu itemChanged: self];
}
- (NSMenu*) submenu
{
return _submenu;
}
- (void) setTitle: (NSString*)aString
{
if (nil == aString)
aString = @"";
if ([_title isEqualToString:aString])
return; // no change
ASSIGNCOPY(_title, aString);
[self _updateKeyEquivalent];
[_menu itemChanged: self];
}
- (NSString*) title
{
return _title;
}
- (BOOL) isSeparatorItem
{
return NO;
}
- (void) setKeyEquivalent: (NSString*)aKeyEquivalent
{
if (nil == aKeyEquivalent)
{
/* We warn about nil for compatibiliy with MacOS X, which refuses
nil. */
NSDebugMLLog(@"MacOSXCompatibility",
@"Attempt to use nil as key equivalent");
aKeyEquivalent = @"";
}
if ([_keyEquivalent isEqualToString:aKeyEquivalent])
return; // no change
ASSIGNCOPY(_keyEquivalent, aKeyEquivalent);
[_menu itemChanged: self];
}
- (NSString*) keyEquivalent
{
if (usesUserKeyEquivalents)
return [self userKeyEquivalent];
else
return _keyEquivalent;
}
- (void) setKeyEquivalentModifierMask: (NSUInteger)mask
{
if (_keyEquivalentModifierMask == mask)
return; // no change
_keyEquivalentModifierMask = mask;
[_menu itemChanged: self];
}
- (NSUInteger) keyEquivalentModifierMask
{
return _keyEquivalentModifierMask;
}
- (NSString*) userKeyEquivalent
{
NSString *userKeyEquivalent = [(NSDictionary*)[[[NSUserDefaults standardUserDefaults]
persistentDomainForName: NSGlobalDomain]
objectForKey: @"NSCommandKeys"]
objectForKey: _title];
if (nil == userKeyEquivalent)
userKeyEquivalent = @"";
return userKeyEquivalent;
}
- (NSUInteger) userKeyEquivalentModifierMask
{
// FIXME
return NSCommandKeyMask;
}
- (void) setMnemonicLocation: (NSUInteger)location
{
if (_mnemonicLocation == location)
return; // no change
_mnemonicLocation = location;
[_menu itemChanged: self];
}
- (NSUInteger) mnemonicLocation
{
if (_mnemonicLocation != 255)
return _mnemonicLocation;
else
return NSNotFound;
}
- (NSString*) mnemonic
{
if (_mnemonicLocation != 255)
return [_title substringWithRange: NSMakeRange(_mnemonicLocation, 1)];
else
return @"";
}
- (void) setTitleWithMnemonic: (NSString*)stringWithAmpersand
{
NSUInteger location = [stringWithAmpersand rangeOfString: @"&"].location;
[self setTitle: [stringWithAmpersand stringByReplacingString: @"&"
withString: @""]];
[self setMnemonicLocation: location];
}
- (void) setImage: (NSImage *)image
{
NSAssert(image == nil || [image isKindOfClass: imageClass],
NSInvalidArgumentException);
if (_image == image)
return; // no change
ASSIGN(_image, image);
[_menu itemChanged: self];
}
- (NSImage*) image
{
return _image;
}
- (void) setState: (NSInteger)state
{
if (_state == state)
return;
_state = state;
_changesState = YES;
[_menu itemChanged: self];
}
- (NSInteger) state
{
return _state;
}
- (void) setOnStateImage: (NSImage*)image
{
NSAssert(image == nil || [image isKindOfClass: imageClass],
NSInvalidArgumentException);
if (_onStateImage == image)
return; // no change
ASSIGN(_onStateImage, image);
[_menu itemChanged: self];
}
- (NSImage*) onStateImage
{
return _onStateImage;
}
- (void) setOffStateImage: (NSImage*)image
{
NSAssert(image == nil || [image isKindOfClass: imageClass],
NSInvalidArgumentException);
if (_offStateImage == image)
return; // no change
ASSIGN(_offStateImage, image);
[_menu itemChanged: self];
}
- (NSImage*) offStateImage
{
return _offStateImage;
}
- (void) setMixedStateImage: (NSImage*)image
{
NSAssert(image == nil || [image isKindOfClass: imageClass],
NSInvalidArgumentException);
if (_mixedStateImage == image)
return; // no change
ASSIGN(_mixedStateImage, image);
[_menu itemChanged: self];
}
- (NSImage*) mixedStateImage
{
return _mixedStateImage;
}
- (void) setEnabled: (BOOL)flag
{
if (flag == _enabled)
return;
_enabled = flag;
[_menu itemChanged: self];
}
- (BOOL) isEnabled
{
return _enabled;
}
- (void) setTarget: (id)anObject
{
if (_target == anObject)
return;
_target = anObject;
[_menu itemChanged: self];
}
- (id) target
{
return _target;
}
- (void) setAction: (SEL)aSelector
{
if (_action == aSelector)
return;
_action = aSelector;
[_menu itemChanged: self];
}
- (SEL) action
{
return _action;
}
- (void) setTag: (NSInteger)anInt
{
_tag = anInt;
}
- (NSInteger) tag
{
return _tag;
}
- (void) setRepresentedObject: (id)anObject
{
ASSIGN(_representedObject, anObject);
}
- (id) representedObject
{
return _representedObject;
}
- (NSAttributedString *)attributedTitle
{
// FIXME
return nil;
}
-(void) setAttributedTitle: (NSAttributedString *)title
{
// FIXME
[self setTitle: [title string]];
}
- (NSInteger)indentationLevel
{
return _indentation;
}
- (void)setIndentationLevel: (NSInteger)level
{
_indentation = level;
}
- (BOOL)isAlternate
{
return _isAlternate;
}
- (void) setAlternate: (BOOL)isAlternate
{
_isAlternate = isAlternate;
}
- (void) setToolTip: (NSString *)toolTip
{
ASSIGN(_toolTip, toolTip);
}
- (NSString *) toolTip
{
return _toolTip;
}
/*
* NSCopying protocol
*/
- (id) copyWithZone: (NSZone*)zone
{
NSMenuItem *copy = (NSMenuItem*)NSCopyObject (self, 0, zone);
// We reset the menu to nil to allow the reuse of the copy
copy->_menu = nil;
copy->_title = [_title copyWithZone: zone];
copy->_keyEquivalent = [_keyEquivalent copyWithZone: zone];
copy->_image = [_image copyWithZone: zone];
copy->_onStateImage = [_onStateImage copyWithZone: zone];
copy->_offStateImage = [_offStateImage copyWithZone: zone];
copy->_mixedStateImage = [_mixedStateImage copyWithZone: zone];
copy->_representedObject = RETAIN(_representedObject);
copy->_submenu = [_submenu copy];
copy->_toolTip = RETAIN(_toolTip);
copy->_target = _target;
return copy;
}
/*
* NSCoding protocol
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
if ([aCoder allowsKeyedCoding])
{
if ([self isSeparatorItem])
{
[aCoder encodeBool: YES forKey: @"NSIsSeparator"];
}
[aCoder encodeObject: _title forKey: @"NSTitle"];
[aCoder encodeObject: NSStringFromSelector(_action) forKey: @"NSAction"];
[aCoder encodeObject: _keyEquivalent forKey: @"NSKeyEquiv"];
[aCoder encodeObject: _onStateImage forKey: @"NSOnImage"];
[aCoder encodeObject: _offStateImage forKey: @"NSOffImage"]; // ???????
[aCoder encodeObject: _mixedStateImage forKey: @"NSMixedImage"];
[aCoder encodeObject: _target forKey: @"NSTarget"];
[aCoder encodeObject: _menu forKey: @"NSMenu"];
// If the menu is owned by a popup, then don't encode the children.
// This prevents an assertion error in IB as these keys should not
// be present in a menu item when it's encoded as part of a popup.
if([_menu _ownedByPopUp] == NO)
{
[aCoder encodeObject: _submenu forKey: @"NSSubmenu"];
}
[aCoder encodeInt: _keyEquivalentModifierMask forKey: @"NSKeyEquivModMask"];
[aCoder encodeInt: _mnemonicLocation forKey: @"NSMnemonicLoc"];
[aCoder encodeInt: _state forKey: @"NSState"];
[aCoder encodeBool: ![self isEnabled] forKey: @"NSIsDisabled"];
if (_tag)
{
[aCoder encodeInt: _tag forKey: @"NSTag"];
}
}
else
{
[aCoder encodeObject: _title];
[aCoder encodeObject: _keyEquivalent];
[aCoder encodeValueOfObjCType: @encode(NSUInteger) at: &_keyEquivalentModifierMask];
[aCoder encodeValueOfObjCType: @encode(NSUInteger) at: &_mnemonicLocation];
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_state];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_enabled];
[aCoder encodeObject: _image];
[aCoder encodeObject: _onStateImage];
[aCoder encodeObject: _offStateImage];
[aCoder encodeObject: _mixedStateImage];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_changesState];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_tag];
[aCoder encodeConditionalObject: _representedObject];
[aCoder encodeObject: _submenu];
[aCoder encodeConditionalObject: _target];
// version 3
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isAlternate];
[aCoder encodeValueOfObjCType: @encode(char) at: &_indentation];
[aCoder encodeObject: _toolTip];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
if ([aDecoder allowsKeyedCoding])
{
NSString *title;
NSString *action;
NSString *key;
BOOL isSeparator = NO;
int keyMask;
if ([aDecoder containsValueForKey: @"NSIsSeparator"])
{
isSeparator = [aDecoder decodeBoolForKey: @"NSIsSeparator"];
}
if (isSeparator && ![self isSeparatorItem])
{
RELEASE(self);
//
// An object returned from initWithCoder:
// should not be autoreleased. Do a retain
// to prevent it from being released automatically.
//
self = RETAIN([NSMenuItem separatorItem]);
}
//
// Not retained, because we're calling the designated init with
// the values.
//
title = [aDecoder decodeObjectForKey: @"NSTitle"];
action = [aDecoder decodeObjectForKey: @"NSAction"];
key = [aDecoder decodeObjectForKey: @"NSKeyEquiv"];
self = [self initWithTitle: title
action: NSSelectorFromString(action)
keyEquivalent: key];
//[aDecoder decodeObjectForKey: @"NSMenu"];
if ([aDecoder containsValueForKey: @"NSTarget"])
{
id target = [aDecoder decodeObjectForKey: @"NSTarget"];
[self setTarget: target];
}
if ([aDecoder containsValueForKey: @"NSMixedImage"])
{
NSImage *mixedImage = [aDecoder decodeObjectForKey: @"NSMixedImage"];
[self setMixedStateImage: mixedImage];
}
if ([aDecoder containsValueForKey: @"NSOnImage"])
{
NSImage *onImage = [aDecoder decodeObjectForKey: @"NSOnImage"];
[self setOnStateImage: onImage];
}
if ([aDecoder containsValueForKey: @"NSSubmenu"])
{
NSMenu *submenu = [aDecoder decodeObjectForKey: @"NSSubmenu"];
[self setSubmenu: submenu];
}
// Set the key mask regardless of whether it is present;
// i.e. set it to 0 if it is not present in the nib.
keyMask = [aDecoder decodeIntForKey: @"NSKeyEquivModMask"];
[self setKeyEquivalentModifierMask: keyMask];
if ([aDecoder containsValueForKey: @"NSMnemonicLoc"])
{
int loc = [aDecoder decodeIntForKey: @"NSMnemonicLoc"];
[self setMnemonicLocation: loc];
}
if ([aDecoder containsValueForKey: @"NSState"])
{
_state = [aDecoder decodeIntForKey: @"NSState"];
}
if ([aDecoder containsValueForKey: @"NSIsDisabled"])
{
BOOL flag = [aDecoder decodeBoolForKey: @"NSIsDisabled"];
[self setEnabled: !flag];
}
if ([aDecoder containsValueForKey: @"NSTag"])
{
int tag = [aDecoder decodeIntForKey: @"NSTag"];
[self setTag: tag];
}
}
else
{
int version = [aDecoder versionForClassName:
@"NSMenuItem"];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_title];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalent];
[aDecoder decodeValueOfObjCType: @encode(NSUInteger) at: &_keyEquivalentModifierMask];
if (version <= 3)
{
_keyEquivalentModifierMask = _keyEquivalentModifierMask << 16;
}
[aDecoder decodeValueOfObjCType: @encode(NSUInteger) at: &_mnemonicLocation];
[aDecoder decodeValueOfObjCType: @encode(NSInteger) at: &_state];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_enabled];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_image];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_onStateImage];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_offStateImage];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_mixedStateImage];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_changesState];
if (version == 1)
{
_target = [aDecoder decodeObject];
}
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
[aDecoder decodeValueOfObjCType: @encode(NSInteger) at: &_tag];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_representedObject];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_submenu];
if (version >= 2)
{
_target = [aDecoder decodeObject];
}
if (version >= 3)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isAlternate];
[aDecoder decodeValueOfObjCType: @encode(char) at: &_indentation];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_toolTip];
}
}
[self _updateKeyEquivalent];
return self;
}
- (void) bind: (NSString *)binding
toObject: (id)anObject
withKeyPath: (NSString *)keyPath
options: (NSDictionary *)options
{
if ([binding hasPrefix: NSEnabledBinding])
{
GSKeyValueBinding *kvb;
[self unbind: binding];
kvb = [[GSKeyValueAndBinding alloc] initWithBinding: NSEnabledBinding
withName: binding
toObject: anObject
withKeyPath: keyPath
options: options
fromObject: self];
// The binding will be retained in the binding table
RELEASE(kvb);
}
else
{
[super bind: binding
toObject: anObject
withKeyPath: keyPath
options: options];
}
}
@end
@implementation NSMenuItem (GNUstepExtra)
/*
* These methods support the special arranging in columns of menu
* items in GNUstep. There's no need to use them outside but if
* they are used the display is more pleasant.
*/
- (void) setChangesState: (BOOL)flag
{
_changesState = flag;
}
- (BOOL) changesState
{
return _changesState;
}
@end
|