mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 21:27:56 -05:00
Simplify creating an OakEncodingPopUpButton
We now do the (sort of required) sizeToFit in the initializer. Users can still bypass this by using initWithFrame:pullsDown: instead of init:.
This commit is contained in:
@@ -74,12 +74,7 @@ namespace
|
||||
{
|
||||
// TODO transliteration / BOM check box
|
||||
NSAlert* alert = [[NSAlert alertWithMessageText:[NSString stringWithCxxString:text::format("Unable to save document using “%s” as encoding.", encoding.c_str())] defaultButton:@"Retry" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Please choose another encoding:"] retain];
|
||||
OakEncodingPopUpButton* encodingChooser = [[[OakEncodingPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO] autorelease];
|
||||
[encodingChooser sizeToFit];
|
||||
NSRect frame = [encodingChooser frame];
|
||||
if(NSWidth(frame) > 200)
|
||||
[encodingChooser setFrameSize:NSMakeSize(200, NSHeight(frame))];
|
||||
[alert setAccessoryView:encodingChooser];
|
||||
[alert setAccessoryView:[[OakEncodingPopUpButton new] autorelease]];
|
||||
[alert beginSheetModalForWindow:_window modalDelegate:_self didEndSelector:@selector(encodingSheetDidEnd:returnCode:contextInfo:) contextInfo:NULL];
|
||||
[[alert window] recalculateKeyViewLoop];
|
||||
}
|
||||
|
||||
@@ -187,6 +187,17 @@ namespace // PopulateMenu{Flat,Hierarchical}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if(self = [self initWithFrame:NSZeroRect pullsDown:NO])
|
||||
{
|
||||
[self sizeToFit];
|
||||
if(NSWidth([self frame]) > 200)
|
||||
[self setFrameSize:NSMakeSize(200, NSHeight([self frame]))];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
Reference in New Issue
Block a user