public override bool DoCommandBySelector(
     NSControl control,
     NSTextView textView,
     Selector commandSelector)
 {
     if (commandSelector.Name == "insertNewline:")
     {
         textView.InsertText(new NSString(Environment.NewLine));
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        public override bool DoCommandBySelector(NSControl control, NSTextView textView, Selector commandSelector)
        {
            switch (commandSelector.Name)
            {
            case "insertNewline:":
                if (_textBox.TryGetTarget(out var textBox) && textBox.AcceptsReturn)
                {
                    textView.InsertText((NSString)"\n");
                    return(true);
                }

                break;
            }

            return(false);
        }
Exemplo n.º 3
0
        public bool Run(ExceptionDialogData data)
        {
            using (var alert = new NSAlert()) {
                alert.AlertStyle = NSAlertStyle.Critical;

                var    pix = ImageService.GetPixbuf(Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
                byte[] buf = pix.SaveToBuffer("tiff");
                alert.Icon = new NSImage(NSData.FromArray(buf));

                alert.MessageText     = data.Title ?? "Some Message";
                alert.InformativeText = data.Message ?? "Some Info";

                if (data.Exception != null)
                {
                    var text = new NSTextView(new RectangleF(0, 0, float.MaxValue, float.MaxValue));
                    text.HorizontallyResizable             = true;
                    text.TextContainer.ContainerSize       = new SizeF(float.MaxValue, float.MaxValue);
                    text.TextContainer.WidthTracksTextView = false;
                    text.InsertText(new NSString(data.Exception.ToString()));
                    text.Editable = false;

                    var scrollView = new NSScrollView(new RectangleF(0, 0, 450, 150))
                    {
                        HasHorizontalScroller = true,
                        DocumentView          = text,
                    };
                    ;
                    alert.AccessoryView = scrollView;
                }

                // Hack up a slightly wider than normal alert dialog. I don't know how to do this in a nicer way
                // as the min size constraints are apparently ignored.
                var frame = ((NSPanel)alert.Window).Frame;
                ((NSPanel)alert.Window).SetFrame(new RectangleF(frame.X, frame.Y, Math.Max(frame.Width, 600), frame.Height), true);

                int result = alert.RunModal() - (int)NSAlertButtonReturn.First;

                GtkQuartz.FocusWindow(data.TransientFor ?? MessageService.RootWindow);
            }

            return(true);
        }
		public bool Run (ExceptionDialogData data)
		{
			using (var alert = new NSAlert ()) {
				alert.AlertStyle = NSAlertStyle.Critical;
				
				var pix = ImageService.GetPixbuf (Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
				byte[] buf = pix.SaveToBuffer ("tiff");
				alert.Icon = new NSImage (NSData.FromArray (buf));
				
				alert.MessageText = data.Title ?? "Some Message";
				alert.InformativeText = data.Message ?? "Some Info";

				if (data.Exception != null) {

					var text = new NSTextView (new RectangleF (0, 0, float.MaxValue, float.MaxValue));
					text.HorizontallyResizable = true;
					text.TextContainer.ContainerSize = new SizeF (float.MaxValue, float.MaxValue);
					text.TextContainer.WidthTracksTextView = false;
					text.InsertText (new NSString (data.Exception.ToString ()));
					text.Editable = false;
					
					var scrollView = new NSScrollView (new RectangleF (0, 0, 450, 150)) {
						HasHorizontalScroller = true,
						DocumentView = text,
					};
;
					alert.AccessoryView = scrollView;
				}
				
				// Hack up a slightly wider than normal alert dialog. I don't know how to do this in a nicer way
				// as the min size constraints are apparently ignored.
				var frame = ((NSPanel) alert.Window).Frame;
				((NSPanel) alert.Window).SetFrame (new RectangleF (frame.X, frame.Y, Math.Max (frame.Width, 600), frame.Height), true);
				
				int result = alert.RunModal () - (int)NSAlertButtonReturn.First;
				
				GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow);
			}
			
			return true;
		}
Exemplo n.º 5
0
        public void NSTextInputClient_ShouldInsertText()
        {
            textView.InsertText((NSString)"Test", new NSRange(5, 4));

            Assert.AreEqual(textView.Value, "This Test new string", "NSTextInputClient_ShouldInsertText - Failed to insert text");
        }
Exemplo n.º 6
0
 public static void SetText(this NSTextView textView, string text)
 {
     textView.ClearText();
     textView.InsertText(text.ValueOrEmpty().ToNSString());
 }