Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass first supportedAction as the action to exportAsDrag #1683

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" }
m-sasha marked this conversation as resolved.
Show resolved Hide resolved
}

}

/**
* 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
m-sasha marked this conversation as resolved.
Show resolved Hide resolved
)
}

Expand Down
Loading