Drag and drop?

This topic contains 10 replies, has 6 voices, and was last updated by  SekaiChi 4 months, 1 week ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #3463

    AdamStrange
    Participant

    Does mx2 support dropping of files on the app window?

    If so, how?

    if not, how?

    #3471

    degac
    Participant

    I know (and found in module source) that SDL has an event SDL_DropEvent but not sure if this is implemented/used in MX2 (its defined so I imagine that can be catched).

     

    edit:

    tested using the SDL example, just adding in Select..End Select

    Case SDL_DROPFILE
    Print “Event dropfile”

    edit2:

    looking at the event.monkey2 source it seems that SDL_DROP is not implemented (or maybe I’ve looked in the wrong place! – there are only key, windows and mouse events)

    it seems to works

    #3479

    impixi
    Participant

    Looks like you need to hack Mojo to support dragging items onto the application window.

    Rough “proof of concept” example:

    monkey2/modules/mojo/app/app.monkey2

    Add the following field, property and method to to the AppInstance class:

    [/crayon]

    Add the following function call to the bottom of the AppInstance class constructor, just before the End statement:

    [/crayon]

    Add the following to the Select statement in the DispatchEvent method:

    [/crayon]

    Compile the mojo module. Test it out with the following example.

    sdl2DragTest.monkey2:

    [/crayon]

    As I said, that’s just a proof of concept that works for me (on Windows).

    To make DropEvent behave like the other Mojo event types requires extra work… Something for another time…

    #3488

    Mark Sibly
    Keymaster

    Looks nice and easy, will have a hack at this today.

    #15266

    SekaiChi
    Participant

    Does drag and drop work for both windows and icons? Please create a drag and drop banana how to use it in new releases it could be emmensly useful to have sometimes 🤔

    #15268

    nerobot
    Participant

    It’s easy. Write in your widow constructor

    Works fine on Windows, don’t know about osx.

    #15269

    SekaiChi
    Participant

    it works in macos the same ☺️, also with folders and multiple files is confirmed.

    How about dropping files onto the actual app icon instead of the app window?

    In windows this would mean reading the parameters of the exe file right? What about macOS?

    #15270

    nerobot
    Participant

    Ted2go is supporting drag-into-exe. You can test it on win and mac.

    The code

    #15271

    SekaiChi
    Participant

    I get the error “identifier “MainWindow” Not found?

    #15272

    nerobot
    Participant

    Replace MainWindow.OnFileDropped( arg ) with your code .

    #15273

    SekaiChi
    Participant

    oh gotcha I thought was some clever mechanism to chain parameter/icon input to the window drag and drop input.

     

    for macos you need to edit info.plist to allow dragging to an icon on the desktop or onto the dock

    info.plist  needs the added line:

    Add/Modify public.data mime type

    I can be misstaken as this is all new to me, but am exploring it now. Is this why you can’t drag files onto Monkey2 in the macos dock (or desk) maybe.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.