-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Describe your feature request here
This has been discussed a lot in the past and multiple PoC have been created. As such, this is mostly a tracking issue to have a common place for discussion and linking together information.
One of the main technical challenge that held back the implementation of such an event was the C++ union of SFML 2.x
With SFML 3 and the change to the event API, we should have more flexibility in defining event structures.
Use Cases
Quoting a few people
drag images in an image viewer,
drag programs to a shortcut-management custom window,
drag textures in a game supporting custom textures / make character "modding" more user friendly.
But mostly, something which is always hugely undervalued: editors.
Map editors always benefit from drag-drop. May it be a .lua script of events being copied from another map, may it be map's settings exported in an external ini file, up to the simpler and conventional "drag the file type this editor makes in order to open it", which works from any editor, not only games ones.
~ barnack
Allowing the opening of media files for a media player, save game/project files in some sort of editor (such as a scene designer), or dropping links/images from elsewhere to be modified in app.
~ Ruckamongus
I wouldn't mind using this feature to easily upload skins for user's ship armour, or crawl a resource archive.
~ Turbine
And more...
API Example
Using the example from #2265
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
sf::RenderWindow window(sf::VideoMode(sf::Vector2u{300, 300}), "dnd test", sf::State::Windowed);
window.setFileDroppingEnabled(true);
while(window.isOpen()) {
while(const std::optional event = window.pollEvent()) {
if(event->is<sf::Event::Closed>()) {
window.close();
}
if(const auto dropped = event->getIf<sf::Event::FilesDropped>()) {
for (const auto& item : dropped->filenames)
{
std::cout << "This file was dropped: " << item.toAnsiString() << std::endl;
}
}
}
window.clear();
window.display();
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status