Fix issue with pull down/pop up. Refresh the button

This commit is contained in:
Gregory John Casamento 2024-12-07 20:33:22 -05:00
parent 0f2d8b63b7
commit 40020e9016
5 changed files with 18 additions and 34 deletions

View file

@ -4,6 +4,7 @@
Actions = (
);
Outlets = (
"_prototypePopUp"
);
Super = IBPalette;
};

View file

@ -31,6 +31,9 @@
#include "GormNSPopUpButton.h"
@interface ControlsPalette: IBPalette <IBViewResourceDraggingDelegates>
{
IBOutlet NSPopUpButton *_prototypePopUp;
}
@end
@ -62,18 +65,9 @@
- (void) finishInstantiate
{
/*
NSView *contents;
id v;
contents = [originalWindow contentView];
v = [[GormNSPopUpButton alloc] initWithFrame: NSMakeRect(70, 159, 75, 22)];
[v addItemWithTitle: @"Item 1"];
[v addItemWithTitle: @"Item 2"];
[v addItemWithTitle: @"Item 3"];
[contents addSubview: v];
RELEASE(v);
*/
[_prototypePopUp addItemWithTitle: @"Item #0"];
[_prototypePopUp addItemWithTitle: @"Item #1"];
[_prototypePopUp addItemWithTitle: @"Item #2"];
}
- (void) willInspectObject: (NSNotification *)notification

View file

@ -65,6 +65,7 @@ Class _gormnspopupbuttonCellClass = 0;
* Override this here, since themes may override it.
* Always want to show the menu view since it's editable.
*/
/*
- (void) attachPopUpWithFrame: (NSRect)cellFrame
inView: (NSView *)controlView
{
@ -127,4 +128,6 @@ Class _gormnspopupbuttonCellClass = 0;
name: NSMenuDidSendActionNotification
object: _menu];
}
*/
@end

View file

@ -70,31 +70,17 @@
if (sender == typeMatrix)
{
BOOL pullsDown = [[sender selectedCell] tag] == YES ? YES : NO;
id selectedItem;
id cell = [object cell];
NSLog(@"pullDown = %d", pullsDown);
NSLog(@"cell = %@", cell);
NSArray *itemArray = [[object itemArray] copy];
NSEnumerator *en = [itemArray objectEnumerator];
id o = nil;
[object removeAllItems];
[object setPullsDown: pullsDown];
selectedItem = [object selectedItem];
[object selectItem: nil];
[object selectItem: selectedItem];
[cell setUsesItemFromMenu: YES];
// Set up the form...
[pullDownTitleForm setEnabled: pullsDown];
[[pullDownTitleForm cellAtIndex: 0]
setStringValue: pullsDown ? [object title] : @""];
[pullDownArrowPopUp setEnabled: pullsDown];
if (pullsDown)
while ((o = [en nextObject]) != nil)
{
// TODO: This should be configurable in the future
[cell setPreferredEdge: NSMaxYEdge];
[cell setMenuItem: nil];
[cell setMenuItem: selectedItem];
}
NSLog(@"o = %@", o);
[object addItemWithTitle: [o title]];
}
}
else if (sender == autoenableSwitch)
{