diff options
-rw-r--r-- | TestApps/XamMacTest/Info.plist | 2 | ||||
-rw-r--r-- | Xwt.XamMac/Xwt.Mac/LabelBackend.cs | 24 | ||||
-rw-r--r-- | Xwt.XamMac/Xwt.Mac/TextEntryBackend.cs | 23 |
3 files changed, 48 insertions, 1 deletions
diff --git a/TestApps/XamMacTest/Info.plist b/TestApps/XamMacTest/Info.plist index deb645ae..b305a41c 100644 --- a/TestApps/XamMacTest/Info.plist +++ b/TestApps/XamMacTest/Info.plist @@ -9,7 +9,7 @@ <key>CFBundleVersion</key> <string>1</string> <key>LSMinimumSystemVersion</key> - <string>10.6</string> + <string>10.7</string> <key>NSPrincipalClass</key> <string>NSApplication</string> </dict> diff --git a/Xwt.XamMac/Xwt.Mac/LabelBackend.cs b/Xwt.XamMac/Xwt.Mac/LabelBackend.cs index cab91899..ba87df67 100644 --- a/Xwt.XamMac/Xwt.Mac/LabelBackend.cs +++ b/Xwt.XamMac/Xwt.Mac/LabelBackend.cs @@ -271,6 +271,30 @@ namespace Xwt.Mac { CGColor bgColor; + public CustomTextFieldCell () + { + } + + protected CustomTextFieldCell (IntPtr ptr) : base (ptr) + { + } + + /// <summary> + /// Like what happens for the ios designer, AppKit can sometimes clone the native `NSTextFieldCell` using the Copy (NSZone) + /// method. We *need* to ensure we can create a new managed wrapper for the cloned native object so we need the IntPtr + /// constructor. NOTE: By keeping this override in managed we ensure the new wrapper C# object is created ~immediately, + /// which makes it easier to debug issues. + /// </summary> + /// <returns>The copy.</returns> + /// <param name="zone">Zone.</param> + public override NSObject Copy(NSZone zone) + { + // Don't remove this override because the comment on this explains why we need this! + var newCell = (CustomTextFieldCell)base.Copy(zone); + newCell.bgColor = bgColor; + return newCell; + } + public void SetBackgroundColor (CGColor c) { bgColor = c; diff --git a/Xwt.XamMac/Xwt.Mac/TextEntryBackend.cs b/Xwt.XamMac/Xwt.Mac/TextEntryBackend.cs index e6d81734..fe11c70f 100644 --- a/Xwt.XamMac/Xwt.Mac/TextEntryBackend.cs +++ b/Xwt.XamMac/Xwt.Mac/TextEntryBackend.cs @@ -356,6 +356,29 @@ namespace Xwt.Mac } + protected CustomCell(IntPtr ptr) : base(ptr) + { + } + + /// <summary> + /// Like what happens for the ios designer, AppKit can sometimes clone the native `NSTextFieldCell` using the Copy (NSZone) + /// method. We *need* to ensure we can create a new managed wrapper for the cloned native object so we need the IntPtr + /// constructor. NOTE: By keeping this override in managed we ensure the new wrapper C# object is created ~immediately, + /// which makes it easier to debug issues. + /// </summary> + /// <returns>The copy.</returns> + /// <param name="zone">Zone.</param> + public override NSObject Copy(NSZone zone) + { + // Don't remove this override because the comment on this explains why we need this! + var newCell = (CustomCell)base.Copy(zone); + newCell.editor = editor; + newCell.selChangeObserver = selChangeObserver; + newCell.Context = Context; + newCell.EventSink = EventSink; + return newCell; + } + public override NSTextView FieldEditorForView (NSView aControlView) { if (editor == null) { |