Comments (5)
You need to call BeginDragDropTarget()
after submitting any widget that you want as a potential drop target. And definitely not inside of a BeginDragDropSource()
conditional. Take a look at the drag&drop copy/swap example in the demo window for reference.
from imgui.
(Note that I added an assert to detect nested BeginDragDropTarget()
/BeginDragDropSource()
, but this specific error won't be caught as it is merely in the conditional block)
from imgui.
@GamingMinds-DanielC yes you are correct let me fix that. Reading through the documentation and applying your feedback I get get to this code.
`
ImGui::BeginMenuBar();
if(ImGui::BeginMenu("Menu")){
ImGui::MenuItem("Item");
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) {
ImGui::SetDragDropPayload("DND_DEMO_CELL", &taken, sizeof(int));
SDL_Log("test works");
ImGui::Text("Swap %s", taken);
ImGui::EndDragDropSource();
}
ImGui::EndMenu();
}
ImGui::EndMenuBar();
ImGui::BeginChild("drop here");
ImGui::EndChild();
if (ImGui::BeginDragDropTarget()) {
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("DND_DEMO_CELL")) {
SDL_Log("Droped :%d", taken);
}
ImGui::EndDragDropTarget();
}
`
It does run, but I am still not able to begin the DragDropSource.(as in I still don't see a tooltip or the SDL.Log).
Am I making any other mistakes?
from imgui.
One mistake I see is that you call ImGui::EndMenuBar()
unconditionally. Everything after ImGui::BeginMenuBar()
up to and including ImGui::EndMenuBar()
must be called if and ONLY if ImGui::BeginMenuBar()
returns true.
That's not why it doesn't work though. I have never tested drag&drop with menu items before, but a quick test suggests that ImGui::MenuItem()
doesn't support it. Since you can put any type of widget inside of a menu, try replacing your menu item with ImGui::Selectable()
, that should work.
from imgui.
Thank you @GamingMinds-DanielC
You're the boss!
@ocornut It would be nice for MenuItem()
to support drag and drop.
Its not a must, since we can exchange it. but it would be convenient and intuitive.
from imgui.
Related Issues (20)
- Misbehaving GUI when i through libigl to use imgui HOT 2
- DXGI warning with DX11 backend about `DXGI_SWAP_EFFECT_DISCARD` HOT 9
- Transparent issue HOT 3
- ImGui Dockspace not working when viewports are enabled HOT 11
- Tabbar containing dockspace HOT 8
- How to dock a window to the size programmatically wthout taking the whole space HOT 3
- Memory leak when rendering with DX11 in C++ HOT 16
- How to display the same texture with different scale modes? HOT 1
- Shortcut routing for an active item HOT 16
- How to hide border from dockspace ?
- altas is null when use llvm HOT 2
- Extend button hitbox HOT 3
- Can InvisibleButton allow size 0? HOT 5
- Slider automatically setting to random large value on load HOT 2
- How to programmatically trigger Table column sorting? HOT 2
- DX12 example exception HOT 1
- Possible bug in TabBarGetCurrentTab HOT 1
- Automatically adjust height of a docking node HOT 4
- Are angled headers reorderable? HOT 1
- imgui_impl_glfw.h has an "imgui.h" header in the global installation with libimgui-dev. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.