Skip to content

Commit

Permalink
Merge pull request #852 from gucio321/fix-dragdrop
Browse files Browse the repository at this point in the history
examples/dragdrop: fix crash
  • Loading branch information
gucio321 authored Sep 17, 2024
2 parents 90c856e + d80a51c commit 4fd8e2a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/dragdrop/dragdrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ func loop() {
g.Custom(func() {
g.Button("Drag me: 9").Build()
if imgui.BeginDragDropSource() {
data := 9
data := int(9)
imgui.SetDragDropPayload(
"DND_DEMO",
uintptr(unsafe.Pointer(&data)),
0,
uint64(unsafe.Sizeof(data)),
)
g.Label("9").Build()
imgui.EndDragDropSource()
Expand All @@ -33,7 +33,7 @@ func loop() {
imgui.SetDragDropPayload(
"DND_DEMO",
uintptr(unsafe.Pointer(&data)),
0,
uint64(unsafe.Sizeof(data)),
)
g.Label("10").Build()
imgui.EndDragDropSource()
Expand All @@ -44,8 +44,8 @@ func loop() {
g.Custom(func() {
if imgui.BeginDragDropTarget() {
payload := imgui.AcceptDragDropPayload("DND_DEMO")
if payload != nil {
dropTarget = fmt.Sprintf("Dropped value: %d", payload.Data())
if payload != nil && payload.CData != nil {
dropTarget = fmt.Sprintf("Dropped value: %d", *(*int)(unsafe.Pointer(payload.Data())))
}
imgui.EndDragDropTarget()
}
Expand Down

0 comments on commit 4fd8e2a

Please sign in to comment.