From 2b7297f879c370e8511500e8850707038e171430 Mon Sep 17 00:00:00 2001 From: Kacper Kasper Date: Tue, 21 Nov 2017 21:15:16 +0100 Subject: [PATCH] DeskCalc: accept file drops. * Fixes #9283. --- src/apps/deskcalc/CalcView.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp index ce1792a8fa..77cceb6980 100644 --- a/src/apps/deskcalc/CalcView.cpp +++ b/src/apps/deskcalc/CalcView.cpp @@ -764,7 +764,25 @@ CalcView::Copy() void CalcView::Paste(BMessage* message) { - // handle color drops first + // handle files first + int32 count; + if (message->GetInfo("refs", NULL, &count) == B_OK) { + entry_ref ref; + ssize_t read; + BFile file; + char buffer[256]; + for (int32 i = 0; i < count; i++) { + if (message->FindRef("refs", i, &ref) == B_OK) { + if (file.SetTo(&ref, B_READ_ONLY) == B_OK) { + read = file.Read(buffer, 255); + buffer[read] = 0; + fExpressionTextView->Insert(buffer); + } + } + } + return; + } + // handle color drops // read incoming color const rgb_color* dropColor = NULL; ssize_t dataSize;