Bug 28735 - NSTextFieldCell.SelectWithFrame needs [NullAllowed]
Summary: NSTextFieldCell.SelectWithFrame needs [NullAllowed]
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 2.0.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: 2.4.0 (C6)
Assignee: Chris Hamons
Depends on:
Reported: 2015-04-03 11:01 UTC by Aaron Bockover [MSFT]
Modified: 2015-04-08 13:57 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Aaron Bockover [MSFT] 2015-04-03 11:01:00 UTC
API introduced in 10.10 on NSTextFieldCell/NSCell/NSControl needs auditing for [NullAllowed]. At a minimum, overriding NSTextFieldCell.SelectWithFrame doesn't work as it should because of a missing [NullAllowed] on the 'NSText editor' argument.

Fortunately in my case, I know a valid non-null editor to pass in (because my NSTextField actually provides a custom editor), but this may not always (actually usually won't) be the case.

These APIs can be used to provide a non-default editing frame for the field (e.g. so that you can then render other things inside the field, but outside of the editable bounds of the cell).

[Register ("ReplEntryCell")]
public class ReplEntryCell : NSTextFieldCell
	public ReplEntryCell (IntPtr handle) : base (handle)

	CGRect AdjustFrame (CGRect cellFrame)
		return new CGRect (cellFrame.X + 20, cellFrame.Y, cellFrame.Width, cellFrame.Height);

	public override void EditWithFrame (CGRect aRect, NSView inView, NSText editor, NSObject delegateObject, NSEvent theEvent)
		base.EditWithFrame (AdjustFrame (aRect),inView,
			// FIXME: should be proxying editor but XM explodes incorrectly
			// with ArgumentNullException; binding needs [NullAllowed]
			delegateObject, theEvent);

	public override void SelectWithFrame (CGRect aRect, NSView inView, NSText editor, NSObject delegateObject, nint selStart, nint selLength)
		base.SelectWithFrame (AdjustFrame (aRect), inView,
			// FIXME: should be proxying editor but XM explodes incorrectly
			// with ArgumentNullException; binding needs [NullAllowed]
			delegateObject, selStart, selLength);

	public override void DrawInteriorWithFrame (CGRect cellFrame, NSView inView)
		base.DrawInteriorWithFrame (AdjustFrame (cellFrame), inView);
Comment 1 Timothy Risi 2015-04-03 19:24:26 UTC
Fixed on master / 81be9b243870e38a4ea24b539142aa05e7252290