diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2014-11-04 17:23:31 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2014-11-04 17:23:31 +0300 |
commit | 5613a032aea64b01dd65919ce52a850b3cd4782d (patch) | |
tree | 11dbfa42835c0ed763b2e540ab758dd0227c67ea /main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs | |
parent | cee5236688d8c233caa487cdb776c9f50a35c3bd (diff) | |
parent | aeabf3a8efc71496e314a110658260503a8ade87 (diff) |
Merge remote-tracking branch 'mono/master' into xs6
Conflicts:
.gitmodules
main/build/MacOSX/monostub.m
main/external/xwt
version-checks
Diffstat (limited to 'main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs')
-rw-r--r-- | main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs b/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs index e9da354089..3266004285 100644 --- a/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs +++ b/main/src/addins/MacPlatform/Dialogs/MacAlertDialogHandler.cs @@ -90,6 +90,7 @@ namespace MonoDevelop.MacIntegration } } + var wrappers = new List<AlertButtonWrapper> (buttons.Count); foreach (var button in buttons) { var label = button.Label; if (button.IsStockButton) @@ -100,7 +101,11 @@ namespace MonoDevelop.MacIntegration if (button == AlertButton.CloseWithoutSave) label = GettextCatalog.GetString ("Don't Save"); - alert.AddButton (label); + var nsbutton = alert.AddButton (label); + var wrapperButton = new AlertButtonWrapper (nsbutton, data.Message, button, alert); + wrappers.Add (wrapperButton); + nsbutton.Target = wrapperButton; + nsbutton.Action = new MonoMac.ObjCRuntime.Selector ("buttonActivatedAction:"); } @@ -179,4 +184,29 @@ namespace MonoDevelop.MacIntegration return true; } } + + class AlertButtonWrapper : NSObject + { + readonly NSButton nsbutton; + readonly MessageDescription message; + readonly AlertButton alertButton; + readonly MonoMac.ObjCRuntime.Selector oldAction; + readonly NSAlert alert; + public AlertButtonWrapper (NSButton nsbutton, MessageDescription message, AlertButton alertButton, NSAlert alert) + { + this.nsbutton = nsbutton; + this.message = message; + this.alertButton = alertButton; + this.alert = alert; + oldAction = nsbutton.Action; + } + + [Export ("buttonActivatedAction:")] + void ButtonActivatedAction () + { + bool close = message.NotifyClicked (alertButton); + if (close) + nsbutton.SendAction (oldAction, alert); + } + } } |