Prevents application crash if OS clipboard is not supported.

This commit is contained in:
BDisp
2021-07-06 17:17:08 +01:00
parent 3c1fa5f2b1
commit 3f7e996187
2 changed files with 9 additions and 2 deletions

View File

@@ -14,14 +14,20 @@ namespace Terminal.Gui {
public static ustring Contents {
get {
try {
return Application.Driver.Clipboard.GetClipboardData ();
if (IsSupported) {
return Application.Driver.Clipboard.GetClipboardData ();
} else {
return contents;
}
} catch (Exception) {
return contents;
}
}
set {
try {
Application.Driver.Clipboard.SetClipboardData (value.ToString ());
if (IsSupported) {
Application.Driver.Clipboard.SetClipboardData (value.ToString ());
}
contents = value;
} catch (Exception) {
contents = value;

View File

@@ -75,6 +75,7 @@ namespace UICatalog {
new StatusItem(Key.F2, "~F2~ Open", () => Open()),
new StatusItem(Key.F3, "~F3~ Save", () => Save()),
new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
new StatusItem(Key.Null, $"OS Clipboard IsSupported : {Clipboard.IsSupported}", null)
});
Top.Add (statusBar);