C++ Handlw DragDrop
andrew k (267) 76 posts |
So I am continuing to learn/play with C++ with TBX and now I have got a simple WIMP app built I was looking into some more advanced features like handling drag and drop and loading writing files. I trying to write a simple test app that will handle a file (just a text file for now) being dropped onto the applications main window and then read the file and do something on the back of that. But I haven’t found any documentation on how to do this with C++? I have searched the PRMS and a few go-to places like Steve Fryatt’s great guides but nothing is jumping out at me. I’m assuming the information is in fact staring me in the face but there’s a good chance I am just missing it due to me still not knowing what to really look for. I’d love someone to write a book on building C++ apps on RISC OS aimed at people who already know how to code in perhaps a modern object oriented language on Windows/Linux/Mac. |
Julie Stamp (8365) 474 posts |
I’ve never done it in TBX, but tbx::OpenerManager.add_opener() might be what you’re after. |
Julie Stamp (8365) 474 posts |
Looking again probably an opener is for when someone double-clicks a file in the Filer; for drag-and-drop onto the app you’ll be wanting tbx::LoaderManager.add_loader() I guess. |
Alan Buckley (167) 233 posts |
Use the Window add_loader method to process a file dropped onto a window. The reference guide installed with TBX has the details. Iconbar has a similar method for a file dropped onto the icon bar. |
andrew k (267) 76 posts |
Thank you both for the reply. Ok trying out Window add_loader is next on my list of things to try with c++ plus TBX. Yes I have been using the user guide a lot and it’s really good so thumbs up for putting it together. Hopefully as I gain a little experience with C++ I will be able to better understand the reference guide a little more. |
andrew k (267) 76 posts |
I have been able to get the add_loader to work from looking at the reference guide and produced the following test app. The second test app I was trying to create an instance of the loader class and pass this to the window.add_loader() method but when I run this and drop a file on the window I get a segmentation error. From googling this is likely to do with how I have created the instance of the loader class but I am not sure how else it can be done.
|