Skip to content

Commit

Permalink
Pass first supportedAction as the action to exportAsDrag (#1683)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-sasha authored Nov 7, 2024
1 parent e7dfb92 commit 15283a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
package androidx.compose.mpp.demo.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.draganddrop.dragAndDropSource
import androidx.compose.foundation.draganddrop.dragAndDropTarget
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -56,7 +54,7 @@ import java.awt.datatransfer.StringSelection
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@OptIn(ExperimentalFoundationApi::class, ExperimentalComposeUiApi::class)
@OptIn(ExperimentalComposeUiApi::class)
@Composable
actual fun DragAndDropExample() {
val exportedText = "Hello, DnD!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ actual class DragAndDropTransferData(
*/
@property:ExperimentalComposeUiApi
val onTransferCompleted: ((userAction: DragAndDropTransferAction?) -> Unit)? = null,
)
) {

init {
require(supportedActions.firstOrNull() != null) { "supportedActions may not be empty" }
}

}

/**
* Represents the actual object transferred during a drag-and-drop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ internal class ComposeTransferHandler(private val rootContainer: JComponent) : T
0,
false
),
// This seems to be ignored, and the initial action is MOVE regardless
MOVE
// This seems to be ignored, other than verifying that it's one of the flags returned in
// `getSourceActions`
transferData.supportedActions.first().awtAction
)
}

Expand Down

0 comments on commit 15283a7

Please sign in to comment.