File drag & drop concept
DanielH

Ok, I've been working on adding drag and drop to a display. After 3 days, I finally got allegro compiled to test. Currently, I am please at the progress, but I would like to change things a bit. Right now the drop copies files to a static string array and any new drops will overwrite the last. I would like to instead append to end some sort of dynamic list.

This is what I have now for an event. Technically it is a display event as you drop the files onto the display.

typedef struct ALLEGRO_DROPFILE_EVENT
{
  _AL_EVENT_HEADER(struct ALLEGRO_DISPLAY)
  int32_t x;
  int32_t y;
  int32_t count;
  const char **filenames;
} ALLEGRO_DROPFILE_EVENT;

#SelectExpand
1#ifndef __al_included_allegro5_dropfile_h 2#define __al_included_allegro5_dropfile_h 3 4#ifdef __cplusplus 5extern "C" { 6#endif 7 8AL_FUNC(bool, al_install_drag_drop, (ALLEGRO_DISPLAY *display)); 9AL_FUNC(void, al_uninstall_drag_drop, (void)); 10 11#ifdef __cplusplus 12 } 13#endif 14 15#endif

  bool processEvent(ALLEGRO_EVENT &event)
  {
    switch (event.type)
    {
    case ALLEGRO_EVENT_DROP_FILES:
    {
      int32_t count = event.drop.count;
      const char **files = event.drop.filenames;

    } break;

...

Thoughts? Suggestions?

Trent Gamblin

Needs to be more generic. Drag and drop just about anything. And needs Mac and Linux support before considered seriously.

Mark Oates

Yea, what Trent said. That was my first thought, too.

The API should allow for any content type (or just supported content types) to be dropped, not just files.

Is allegro dev on GitHub? Where's the main development activity?

Thomas Fjellstrom

Is allegro dev on GitHub? Where's the main development activity?

there's a github mirror, but main repo is on sourceforge.

Gideon Weems

DanielH is on fire. Rock on.

I see no need to go through the trouble of creating a dynamic list, if there's going to be a proper event. Users would handle such events as they see fit, right?

DanielH

I did a simple search and how to add drag drop to a program was using WM_DROPFILES message. So, that's what I focused on.

Adding support for data is similar to clipboard access. Will have to look into that.

Thread #614921. Printed from Allegro.cc