[Mono-osx] [MonoMac] MM Add-in templates

Michael Hutchinson m.j.hutchinson at gmail.com
Fri Jan 28 14:03:38 EST 2011


On Fri, Jan 28, 2011 at 11:24 AM, kjpou <kjpou at pt.lu> wrote:
> I thought about the Register as well but the way I am using it there was
> no need to add the Register.  Here is the only way I have been using these.
>
> Within my nib I create a subclass of a NSView with the name of the class
> I am going to use for example MyCustomView.  Then on the Custom NSView
> that I add to the ContentView I change the Type to MyCustomView within
> IB.  When I save this it is automatically sent back to the designer
> class via the MonoDevelop Bridge with IB.
>
>     // Should subclass MonoMac.AppKit.NSView
>     [MonoMac.Foundation.Register("MyCustomView")]
>     public partial class MyCustomView {
>     }
>
> This automatically is registered and is marked as partial.  Thus you can
> not decorate with Register nor mark the class as non partial.
>
> As I said probably a little short sighted.

I see, so you are defining the class in the nib file, not just using
it. There are two problems with this:
* you cannot use your custom view in more than one nib file, since the
register will be generated in both vases.
* the C# namespace of the nib's designer class and the the custom view
will have to match.
* the class is partial across two locations with no intuitive relationship.

The "correct" solution to this is nonpartial class with register
attribute, but in order to work completely smoothly it would
necessitate two nontrivial features:
* have MD synch classes defined in C# code into the nib files.
* have the MD code generator use the project type database to resolve
obj-c types to types registered in C# in the project and libraries,
not just MonoMac.dll (I have some proof of concept code for this if
anyone else want to take it on).

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Mono-osx mailing list