Permalink
Browse files

Fixed the Multiline for textboxes.

  • Loading branch information...
1 parent 4f56bae commit 3f8171fca44427b44cca9f2580ff59d0a92d6827 @Clancey committed Mar 14, 2011
@@ -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()
@@ -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"};
}
@@ -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);
@@ -99,8 +99,6 @@ private void setScrollBars()
}
}
- public bool Multiline{get;set;}
-
#region Events
@@ -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();
@@ -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)
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);

0 comments on commit 3f8171f

Please sign in to comment.