@@ -934,20 +934,20 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
934
934
[self ->handler installCallbacks: actions forButtons: buttons];
935
935
936
936
NSFont * font = [NSFont systemFontOfSize: 0.0 ];
937
- rect.size .width = 300 ;
938
- rect.size .height = 0 ;
939
- rect.origin .x += height;
940
- NSTextView * messagebox = [[NSTextView alloc ] initWithFrame: rect];
937
+ // rect.origin.x is now at the far right edge of the buttons
938
+ // we want the messagebox to take up the rest of the toolbar area
939
+ // Make it a zero-width box if we don't have enough room
940
+ rect.size .width = fmax (bounds.size .width - rect.origin .x , 0 );
941
+ rect.origin .x = bounds.size .width - rect.size .width ;
942
+ NSTextView * messagebox = [[[NSTextView alloc ] initWithFrame: rect] autorelease ];
941
943
messagebox.textContainer .maximumNumberOfLines = 2 ;
942
944
messagebox.textContainer .lineBreakMode = NSLineBreakByTruncatingTail;
945
+ messagebox.alignment = NSTextAlignmentRight;
943
946
[messagebox setFont: font];
944
947
[messagebox setDrawsBackground: NO ];
945
948
[messagebox setSelectable: NO ];
946
949
/* if selectable, the messagebox can become first responder,
947
950
* which is not supposed to happen */
948
- rect = [messagebox frame ];
949
- rect.origin .y = 0.5 * (height - rect.size .height );
950
- [messagebox setFrameOrigin: rect.origin];
951
951
[[window contentView ] addSubview: messagebox];
952
952
[messagebox release ];
953
953
[[window contentView ] display ];
@@ -974,26 +974,31 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
974
974
{
975
975
const char * message;
976
976
977
- if (!PyArg_ParseTuple (args, " y " , &message)) { return NULL ; }
977
+ if (!PyArg_ParseTuple (args, " s " , &message)) { return NULL ; }
978
978
979
979
NSTextView * messagebox = self->messagebox ;
980
980
981
981
if (messagebox) {
982
982
NSString * text = [NSString stringWithUTF8String: message];
983
983
[messagebox setString: text];
984
984
985
- // Adjust width with the window size
985
+ // Adjust width and height with the window size and content
986
986
NSRect rectWindow = [messagebox.superview frame ];
987
987
NSRect rect = [messagebox frame ];
988
+ // Entire region to the right of the buttons
988
989
rect.size .width = rectWindow.size .width - rect.origin .x ;
989
990
[messagebox setFrame: rect];
990
-
991
- // Adjust height with the content size
991
+ // We want to control the vertical position of
992
+ // the rect by the content size to center it vertically
992
993
[messagebox.layoutManager ensureLayoutForTextContainer: messagebox.textContainer];
993
- NSRect contentSize = [messagebox.layoutManager usedRectForTextContainer: messagebox.textContainer];
994
- rect = [messagebox frame ] ;
995
- rect.origin . y = 0.5 * (self-> height - contentSize. size .height ) ;
994
+ NSRect contentRect = [messagebox.layoutManager usedRectForTextContainer: messagebox.textContainer];
995
+ rect. origin . y = 0.5 * (self-> height - contentRect. size . height ) ;
996
+ rect.size . height = contentRect. size .height ;
996
997
[messagebox setFrame: rect];
998
+ // Disable cursorRects so that the cursor doesn't get updated by events
999
+ // in NSApp (like resizing TextViews), we want to handle the cursor
1000
+ // changes from within MPL with set_cursor() ourselves
1001
+ [[messagebox.superview window ] disableCursorRects ];
997
1002
}
998
1003
999
1004
Py_RETURN_NONE;
0 commit comments