* Palettes/2Controls/ControlsPalette.m: implement adding "Prototype" mode to Inspector's popup button for objects with prototype aavailable (mainly NSMatrix).

This commit is contained in:
Sergii Stoian 2020-01-05 03:15:09 +02:00
parent a0702cd9cd
commit cdb2814a8a

View file

@ -30,6 +30,8 @@
#include <AppKit/NSPasteboard.h>
#include <AppKit/NSImage.h>
#include <AppKit/NSSound.h>
#include <InterfaceBuilder/IBInspectorManager.h>
#include <InterfaceBuilder/IBInspectorMode.h>
#include "GormNSPopUpButton.h"
@interface ControlsPalette: IBPalette <IBViewResourceDraggingDelegates>
@ -44,6 +46,13 @@
// Make ourselves a delegate, so that when the sound/image is dragged in,
// this code is called...
[NSView registerViewResourceDraggingDelegate: self];
// subscribe to the notification...
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(willInspectObject:)
name: IBWillInspectObjectNotification
object: nil];
}
return self;
@ -69,6 +78,22 @@
RELEASE(v);
}
- (void) willInspectObject: (NSNotification *)notification
{
id o = [notification object];
if ([o respondsToSelector: @selector(prototype)])
{
id prototype = [o prototype];
NSString *ident = NSStringFromClass([prototype class]);
[[IBInspectorManager sharedInspectorManager]
addInspectorModeWithIdentifier: ident
forObject: o
localizedLabel: _(@"Prototype")
inspectorClassName: [prototype inspectorClassName]
ordering: -1.0];
}
}
/**
* Ask if the view accepts the object.
*/