Deactivated the current font button on window close and implemented cleanup, both on OS X.
This commit is contained in:
parent
c5f6a09200
commit
b6a396dd4a
|
@ -2,7 +2,6 @@
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// TODO drag and drop fonts? what other interactions does NSColorWell allow that we can do for fonts?
|
// TODO drag and drop fonts? what other interactions does NSColorWell allow that we can do for fonts?
|
||||||
// TODO when closing the window, deactivate the current button
|
|
||||||
|
|
||||||
@interface fontButton : NSButton {
|
@interface fontButton : NSButton {
|
||||||
uiFontButton *libui_b;
|
uiFontButton *libui_b;
|
||||||
|
@ -13,6 +12,7 @@
|
||||||
- (IBAction)fontButtonClicked:(id)sender;
|
- (IBAction)fontButtonClicked:(id)sender;
|
||||||
- (void)activateFontButton;
|
- (void)activateFontButton;
|
||||||
- (void)deactivateFontButton:(BOOL)activatingAnother;
|
- (void)deactivateFontButton:(BOOL)activatingAnother;
|
||||||
|
- (void)deactivateOnClose:(NSNotification *)note;
|
||||||
- (uiDrawTextFont *)libuiFont;
|
- (uiDrawTextFont *)libuiFont;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -51,6 +51,15 @@ struct uiFontButton {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
// clean up notifications
|
||||||
|
if (activeFontButton == self)
|
||||||
|
[self deactivateFontButton:NO];
|
||||||
|
[self->libui_font release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateFontButtonLabel
|
- (void)updateFontButtonLabel
|
||||||
{
|
{
|
||||||
NSString *title;
|
NSString *title;
|
||||||
|
@ -80,6 +89,10 @@ struct uiFontButton {
|
||||||
[sfm setSelectedFont:self->libui_font isMultiple:NO];
|
[sfm setSelectedFont:self->libui_font isMultiple:NO];
|
||||||
[sfm orderFrontFontPanel:self];
|
[sfm orderFrontFontPanel:self];
|
||||||
activeFontButton = self;
|
activeFontButton = self;
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(deactivateOnClose:)
|
||||||
|
name:NSWindowWillCloseNotification
|
||||||
|
object:[NSFontPanel sharedFontPanel]];
|
||||||
[self setState:NSOnState];
|
[self setState:NSOnState];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,9 +105,17 @@ struct uiFontButton {
|
||||||
if (!activatingAnother)
|
if (!activatingAnother)
|
||||||
[[NSFontPanel sharedFontPanel] orderOut:self];
|
[[NSFontPanel sharedFontPanel] orderOut:self];
|
||||||
activeFontButton = nil;
|
activeFontButton = nil;
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
|
name:NSWindowWillCloseNotification
|
||||||
|
object:[NSFontPanel sharedFontPanel]];
|
||||||
[self setState:NSOffState];
|
[self setState:NSOffState];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)deactivateOnClose:(NSNotification *)note
|
||||||
|
{
|
||||||
|
[self deactivateFontButton:NO];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)changeFont:(id)sender
|
- (void)changeFont:(id)sender
|
||||||
{
|
{
|
||||||
NSFontManager *fm;
|
NSFontManager *fm;
|
||||||
|
|
Loading…
Reference in New Issue