Skip to content

Commit

Permalink
Merge pull request #2521 from cwensley/curtis/mac-add-more-nativehand…
Browse files Browse the repository at this point in the history
…le-ctors

Mac: Add more NativeHandle constructors and prevent NRE's with TextBox.
  • Loading branch information
cwensley authored Jul 14, 2023
2 parents 2b141d2 + 4f986f0 commit 90dbad2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/Eto.Mac/Forms/Controls/DrawableHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public class DrawableHandler : MacPanel<DrawableHandler.EtoDrawableView, Drawabl
public class EtoDrawableView : MacPanelView
{
DrawableHandler Drawable => Handler as DrawableHandler;

public EtoDrawableView()
{
}

public EtoDrawableView(NativeHandle handle) : base(handle)
{
}

public override void DrawRect(CGRect dirtyRect)
{
Expand Down
8 changes: 7 additions & 1 deletion src/Eto.Mac/Forms/Controls/GroupBoxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ public class GroupBoxHandler : MacPanel<NSBox, GroupBox, GroupBox.ICallback>, Gr
/// </summary>
public class EtoContentView : MacPanelView
{

public EtoContentView()
{
}

public EtoContentView(NativeHandle handle) : base(handle)
{
}
}

public class EtoBox : NSBox, IMacControl
Expand Down
6 changes: 6 additions & 0 deletions src/Eto.Mac/Forms/Controls/PanelHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ public class PanelHandler : MacPanel<NSView, Panel, Panel.ICallback>, Panel.IHan
{
public class EtoPanelView : MacPanelView
{
public EtoPanelView()
{
}
public EtoPanelView(NativeHandle handle) : base(handle)
{
}
}

protected override NSView CreateControl() => new EtoPanelView();
Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/Controls/ScrollableHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public EtoDocumentView()
{
}

public EtoDocumentView(IntPtr handle)
public EtoDocumentView(NativeHandle handle)
: base(handle)
{

Expand Down
6 changes: 3 additions & 3 deletions src/Eto.Mac/Forms/Controls/TextBoxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public class EtoTextField : NSTextField, IMacControl, ITextBoxWithMaxLength
{
public WeakReference WeakHandler { get; set; }

IMacViewHandler Handler => WeakHandler.Target as IMacViewHandler;
IMacText TextHandler => WeakHandler.Target as IMacText;
ITextBoxWithMaxLength MaxLengthHandler => WeakHandler.Target as ITextBoxWithMaxLength;
IMacViewHandler Handler => WeakHandler?.Target as IMacViewHandler;
IMacText TextHandler => WeakHandler?.Target as IMacText;
ITextBoxWithMaxLength MaxLengthHandler => WeakHandler?.Target as ITextBoxWithMaxLength;

public int MaxLength { get { return MaxLengthHandler?.MaxLength ?? 0; } }

Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/MacWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public EtoContentView()
{
}

public EtoContentView(IntPtr handle) : base(handle)
public EtoContentView(NativeHandle handle) : base(handle)
{
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Eto.Mac/Forms/TableLayoutHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class EtoTableLayoutView : MacEventView
{
new TableLayoutHandler Handler => (TableLayoutHandler)base.Handler;

public EtoTableLayoutView(NativeHandle handle) : base(handle)
{
}

public EtoTableLayoutView()
{
AutoresizesSubviews = false;
Expand Down

0 comments on commit 90dbad2

Please sign in to comment.