summaryrefslogtreecommitdiff
path: root/src/Fl_Message.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2022-02-09 16:32:48 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2022-02-09 16:33:55 +0100
commitf6c2531b5b4d939352dccd9f8295f4471d7e1c4c (patch)
treeb9c81c629a4be92d0f0e893ca79bab30e096dc19 /src/Fl_Message.cxx
parent9a326dbe012a2ac180cf4350c8199a9550e836f4 (diff)
Enable end user to copy standard dialog text to clipboard (#388)
All standard dialogs like fl_message() now handle command-c (macOS) and ctrl-c (other platforms) to copy the message text of standard dialogs to the clipboard as requested by GitHub Issue #388.
Diffstat (limited to 'src/Fl_Message.cxx')
-rw-r--r--src/Fl_Message.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/Fl_Message.cxx b/src/Fl_Message.cxx
index 5c27d2f89..970dde3f4 100644
--- a/src/Fl_Message.cxx
+++ b/src/Fl_Message.cxx
@@ -1,7 +1,7 @@
//
// Common dialog implementation for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2021 by Bill Spitzak and others.
+// Copyright 1998-2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -149,7 +149,7 @@ Fl_Message::Fl_Message(const char *iconlabel)
// create widgets
window_ = new Fl_Window(400, 150, NULL);
- message_ = new Fl_Box(60, 25, 340, 20);
+ message_ = new Fl_Message_Box(60, 25, 340, 20);
message_->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_WRAP);
input_ = new Fl_Input(60, 37, 340, 23);
@@ -544,6 +544,24 @@ void Fl_Message::icon_label(const char *str) {
message_icon_label_ = str;
}
+// handle ctrl-c (command-c on macOS) to copy message text
+
+int Fl_Message_Box::handle(int e) {
+ unsigned int mods = Fl::event_state() & (FL_META|FL_CTRL|FL_ALT);
+ switch (e) {
+ case FL_KEYBOARD:
+ case FL_SHORTCUT:
+ if (Fl::event_key() == 'c' && mods == FL_COMMAND) {
+ Fl::copy(label(), strlen(label()), 1);
+ return 1;
+ }
+ break;
+ default:
+ break;
+ }
+ return Fl_Box::handle(e);
+}
+
/**
\}
\endcond