From a37b44fabbfe9db5e10bad4c1a3e67c3d55ccae8 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 26 Sep 2012 22:22:37 +0100 Subject: You can now copy to clipboard the content of message dialogs. The TfpgMessageDialog and TfpgMessageBox dialogs now support the "copy to clipboard" keyboard shortcuts. This is nice and handy for pasting an error message into an email or something. --- src/gui/fpg_dialogs.pas | 18 +++++++++++++----- src/gui/messagedialog.inc | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/gui/fpg_dialogs.pas b/src/gui/fpg_dialogs.pas index baa2bb92..8f3639e6 100644 --- a/src/gui/fpg_dialogs.pas +++ b/src/gui/fpg_dialogs.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2012 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -450,10 +450,18 @@ end; procedure TfpgMessageBox.FormKeyPressed(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean); begin - if KeyCode = keyEscape then - begin - Consumed := False; - Close; + case CheckClipBoardKey(keycode, shiftstate) of + ckCopy: + begin + fpgClipboard.Text := FLines.Text; + Consumed := True; + end; + else + if KeyCode = keyEscape then + begin + Consumed := True; + Close; + end; end; end; diff --git a/src/gui/messagedialog.inc b/src/gui/messagedialog.inc index f5651c7a..0c5c1f24 100644 --- a/src/gui/messagedialog.inc +++ b/src/gui/messagedialog.inc @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2012 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -330,10 +330,18 @@ end; procedure TfpgMessageDialog.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); begin - if keycode = keyEscape then // Esc cancels the dialog - ModalResult := mrCancel + case CheckClipBoardKey(keycode, shiftstate) of + ckCopy: + begin + fpgClipboard.Text := Text + LineEnding + LineEnding + InformativeText; + Consumed := True; + end; else - inherited HandleKeyPress(keycode, shiftstate, consumed); + if keycode = keyEscape then // Esc cancels the dialog + ModalResult := mrCancel + else + inherited HandleKeyPress(keycode, shiftstate, consumed); + end; end; procedure TfpgMessageDialog.PrepareLayout; -- cgit v1.2.3-70-g09d2