Cut / Copy & Paste

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Netzschleicher
Knows some wx things
Knows some wx things
Posts: 25
Joined: Tue Aug 17, 2010 6:48 pm
Location: Germany

Cut / Copy & Paste

Post by Netzschleicher »

Hello there,

in my wxWidgets Application i use Copy & Paste to copy Files from outside my Application into it.
So, Copy & Paste works very fine, but i never find informations to make Cut & Paste working.
Is there an possible automatism in wxWidgets or must i delete the cutted Files on my own if there are
pasted into my Application? And if so, how can i get the information that it is an Cut & Paste operation
and not an Copy & Paste.

To Paste Files into my Application in use following Code:

Code: Select all

void MainWindow::onPasteFile(wxCommandEvent &event) {
    wxClipboard cifeClipboard;

    if (cifeClipboard.Open()) {
        if (cifeClipboard.IsSupported(wxDF_FILENAME)) {
            wxFileDataObject data;
            cifeClipboard.GetData(data);
            int defaultUserNumber = cifeSettings->readInteger("CpmOptions", "DefaultUserNumber", 0);
            wxString textFileEndings = cifeSettings->readString("CpmOptions", "TextfileEndings", "txt pip pas");
            wxArrayString files = data.GetFilenames();

            for (size_t i = 0; i < files.Count(); i++) {
                wxFileName fileName(files[i]);
                wxString fileExt = fileName.GetExt();
                bool isTextFile = textFileEndings.Matches("*" + fileExt + "*");
                cpmtools->writeFileToImage(files[i], defaultUserNumber, isTextFile, true);
            }

            onViewRefresh(event);
        }

        cifeClipboard.Close();
    }
}
Can anyone give me a Help to get Cut & Paste working too?

Greetings
Netzschleicher
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cut / Copy & Paste

Post by ONEEYEMAN »

Hi,
Take a look at the dnd sample.
t shows how to identify the Cut'n'Paste operation.

And yes - you do that yourself.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cut / Copy & Paste

Post by doublemax »

After a little bit of research, I'd say there is no support for this in wxWidgets, at least under Windows.
For cut-and-paste inside your own app, i'm sure there are ways to make it work. But i couldn't find anything that would e.g. work for cutting a file in Windows Explorer and then pasting it into your application. The source is responsible for deleting the file, and there is no way to transfer that information right now in a cross platform way.

Here's how it's supposed to work under Windows:
https://docs.microsoft.com/en-us/window ... operations
Use the source, Luke!
Netzschleicher
Knows some wx things
Knows some wx things
Posts: 25
Joined: Tue Aug 17, 2010 6:48 pm
Location: Germany

Re: Cut / Copy & Paste

Post by Netzschleicher »

Thanks for your replies.
I already thought so to get cut & paste work i must do it at my own.
In the dnd Sample i have nothing found to identify an cut & paste operation.
Can you please give me a hint where in the dnd.cpp file i can find.
I search for an cross Platform solution because my Application runs on Linux an Windows.
Post Reply