diff --git a/GormWindowEditor.m b/GormWindowEditor.m index cb2f1c18..e636b865 100644 --- a/GormWindowEditor.m +++ b/GormWindowEditor.m @@ -186,6 +186,7 @@ _constrainPointToBounds(NSPoint point, NSRect bounds) - (BOOL) acceptsTypeFromArray: (NSArray*)types; - (BOOL) activate; - (id) initWithObject: (id)anObject inDocument: (id)aDocument; +- (void) changeFont: (id) sender; - (void) close; - (void) closeSubeditors; - (void) copySelection; @@ -213,6 +214,11 @@ _constrainPointToBounds(NSPoint point, NSRect bounds) return YES; } +- (BOOL) acceptsFirstResponder +{ + return YES; +} + - (void) encodeWithCoder: (NSCoder*)aCoder { [NSException raise: NSInternalInconsistencyException @@ -1190,6 +1196,24 @@ static BOOL done_editing; return YES; } +- (void)changeFont: (id)sender +{ + NSEnumerator *enumerator = [selection objectEnumerator]; + id anObject; + NSFont *newFont; + while ((anObject = [enumerator nextObject])) + { + if ([anObject respondsToSelector: @selector(font)] + && [anObject respondsToSelector: @selector(setFont:)]) + { + newFont = [sender convertFont: [anObject font]]; + [anObject setFont: newFont]; + } + } + + return; +} + - (void) close { NSAssert(isClosed == NO, NSInternalInconsistencyException); @@ -1399,6 +1423,7 @@ static BOOL done_editing; } [win setContentView: self]; + ASSIGN(document, aDocument); ASSIGN(edited, anObject); selection = [NSMutableArray new]; @@ -1412,6 +1437,7 @@ static BOOL done_editing; [self registerForDraggedTypes: [NSArray arrayWithObjects: IBViewPboardType, GormLinkPboardType, nil]]; + [win setInitialFirstResponder: self]; return self; } @@ -1618,6 +1644,20 @@ static BOOL done_editing; [selection removeObjectAtIndex: count]; } } + if ([selection count] == 1) + { + id item; + item = [selection objectAtIndex: 0]; + if ([item respondsToSelector: @selector(font)] + && [item respondsToSelector: @selector(setFont:)]) + [[NSFontManager sharedFontManager] setSelectedFont: [item font] + isMultiple: NO]; + } + else if ([selection count] > 0) + { + [[NSFontManager sharedFontManager] setSelectedFont: nil + isMultiple: YES]; + } } /* * Now we must let the document (and hence the rest of the app) know