Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed the Multiline for textboxes.

  • Loading branch information...
commit 3f8171fca44427b44cca9f2580ff59d0a92d6827 1 parent 4f56bae
James Clancey authored
5 MonoMac.Windows.Forms/CocoaHelpers/TextBoxHelper.cs
View
@@ -66,8 +66,9 @@ internal TextView ()
public override void InsertText (NSObject insertString)
{
- if (((TextBoxBase)Host.Host).Multiline || insertString.ToString () != "\n")
- base.InsertText (insertString);
+ if (!((TextBoxBase)Host.Host).Multiline && insertString.ToString () == "\n")
+ return ;
+ base.InsertText (insertString);
}
public void SetSingleLine()
23 MonoMac.Windows.Forms/CocoaHelpers/ToolBarHelper.cs
View
@@ -2,32 +2,47 @@
using MonoMac.AppKit;
using System.Linq;
using System.Collections.Generic;
+using System.Collections;
namespace System.Windows.Forms
{
public class ToolBarHelper : NSToolbar, IViewHelper
{
public ToolStrip ToolStrip;
- public ToolBarHelper()
+ public ToolBarHelper(ToolStrip parent)
{
- this.Delegate = new ToolBarDelegate();
+ Host = parent;
+ this.Delegate = new ToolBarDelegate();
+ this.AllowsUserCustomization = true;
+ this.DisplayMode = NSToolbarDisplayMode.IconAndLabel;
}
internal class ToolBarDelegate : NSToolbarDelegate
{
public override NSToolbarItem WillInsertItem (NSToolbar toolbar, string itemIdentifier, bool willBeInserted)
{
- throw new NotImplementedException ();
+ var internalToolbar = (ToolBarHelper)toolbar;
+ var item = internalToolbar.ToolStrip.Items[0];
+ var toolbarItem = new NSToolbarItem(itemIdentifier);
+ toolbarItem.Image = item.Image.ToNSImage();
+ toolbarItem.Label = item.Text;
+ toolbarItem.PaletteLabel = item.Text;
+ toolbarItem.ToolTip = item.Text;
+ toolbarItem.VisibilityPriority = 1;
+ return toolbarItem;
+ //throw new NotImplementedException ();
+ //base.WillInsertItem(toolbar,itemIdentifier,willBeInserted);
}
public override string[] AllowedItemIdentifiers (NSToolbar toolbar)
{
var bar = toolbar as ToolBarHelper;
return bar.Items.Select(x=> x.Label).ToArray();
+ return new string[2]{"NSToolbarPrintItemIdentifier","&New Document"};
}
#region implemented abstract members of MonoMac.AppKit.NSToolbarDelegate
public override string[] DefaultItemIdentifiers (NSToolbar toolbar)
{
- return new string[]{"&Save Document"};
+ return new string[]{"NSToolbarPrintItemIdentifier"};
}
3  MonoMac.Windows.Forms/System.Windows.Forms/Control.Cocoa.cs
View
@@ -463,7 +463,8 @@ private void ChangeParent (Control new_parent)
{
var form = (Form)new_parent;
form.m_helper.Toolbar = (ToolStrip)this;
- form.m_helper.ShowsToolbarButton = true;
+ form.m_helper.Toolbar.Visible = true;
+ //form.m_helper.ShowsToolbarButton = true;
}
OnParentChanged (EventArgs.Empty);
2  MonoMac.Windows.Forms/System.Windows.Forms/TextBox.cocoa.cs
View
@@ -99,8 +99,6 @@ private void setScrollBars()
}
}
- public bool Multiline{get;set;}
-
#region Events
1  MonoMac.Windows.Forms/System.Windows.Forms/TextBoxBase.cocoa.cs
View
@@ -29,7 +29,6 @@ protected override void CreateHandle ()
m_helper.TextView.TextContainer.WidthTracksTextView = false;
m_helper.TextView.Font = Font.ToNsFont();
-
//m_helper.ScaleUnitSquareToSize(Util.ScaleSize);
//m_helper.viewDidMoveToSuperview += delegate(object sender, EventArgs e) {
// ViewDidMoveToSuperview();
2  MonoMac.Windows.Forms/System.Windows.Forms/ToolStrip.cocoa.cs
View
@@ -50,7 +50,7 @@ public ToolStrip (params ToolStripItem[] items) : base ()
protected override void CreateHandle ()
{
base.CreateHandle();
- m_helper = new ToolBarHelper();
+ m_helper = new ToolBarHelper(this);
}
public static implicit operator NSToolbar (ToolStrip toolstrip)
1  ToolStripSample/Main.cs
View
@@ -32,6 +32,7 @@ public ToolStripSample ()
rtb = new TextBox ();
rtb.Multiline = true;
+ rtb.Size = this.Size;
rtb.Dock = DockStyle.Fill;
rtb.BorderStyle = BorderStyle.FixedSingle;
rtb.MouseUp += new MouseEventHandler (rtb_MouseUp);
Please sign in to comment.
Something went wrong with that request. Please try again.