mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Prevents application crash if OS clipboard is not supported.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user