JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.33k stars 1.18k forks source link

issues in Menus #2419

Closed changhexuefei closed 2 months ago

changhexuefei commented 2 years ago

Hello,When I use Menus,Menus are nested in the Compose multiplatform's Menu, and the icons in the items are not fully displayed menu_item

eymar commented 2 years ago

Could you please provide a small sample to reproduce the issue?

changhexuefei commented 2 years ago

Hello,Here's the code I used:

fun main() = application{
    var text by remember { mutableStateOf("Hello, World!") }
    val state = rememberWindowState(placement = WindowPlacement.Maximized)
    var isOpen by remember { mutableStateOf(true) }
    val close: () -> Unit = {
        isOpen = false
    }
    if (isOpen) {
        Window(
            title = "Compose for Desktop",
            icon = painterResource("logo/logo.png"),
            onCloseRequest = ::exitApplication,
            state = state
        ) {
            MaterialTheme {
                MenuBar {
                    Menu("文件(V)", mnemonic = 'V') {
                        Item("新建(N)", mnemonic = 'N', onClick = {

                        })

                        Item("打开(O)", mnemonic = 'O', onClick = {

                        })

                        Menu("保存(S)", mnemonic = 'S') {
                            Item("1111", onClick = {})
                            Item("22222", onClick = {})
                        }

                        Item("另存为(M)", mnemonic = 'M', onClick = {

                        })
                        Separator()
                        Item("退出(X)", mnemonic = 'X', onClick = { close() })
                    }
                    Menu("章节(C)", mnemonic = 'C') {

                        Item(
                            "选择章节(C)", mnemonic = 'C',

                            onClick = { },
                        )

                    }
                    Menu("字幕(S)", mnemonic = 'S') {

                        Item(
                            "抄写字幕(T)", mnemonic = 'T',

                            onClick = {

                            },
                        )
                        var showLinkVocabulary by remember { mutableStateOf(false) }

                        //如果当前词库类型为文档就启用

                        Item(
                            "链接字幕词库(L)", mnemonic = 'L',
                            onClick = { },
                        )
                        var showLyricDialog by remember { mutableStateOf(false) }

                        Item(
                            "歌词转字幕(C)", mnemonic = 'C',
                            enabled = true,
                            onClick = { showLyricDialog = true }
                        )
                    }
                    Menu("文本(T)", mnemonic = 'T') {

                        Item(
                            "抄写文本(T)", mnemonic = 'T',
                            enabled = true,
                            onClick = {

                            },
                        )
                        var showTextFormatDialog by remember { mutableStateOf(false) }

                        Item(
                            "文本格式化(F)", mnemonic = 'F',
                            onClick = { showTextFormatDialog = true },
                        )
                    }
                    Menu("复习(F)", mnemonic = 'F') {
                        var showChapterDialog by remember { mutableStateOf(false) }
                        Item(
                            text = "听写复习(F)",
                            mnemonic = 'F',
                            enabled = true,
                            onClick = { showChapterDialog = true }
                        )

                    }
                    var aboutDialogVisible by remember { mutableStateOf(false) }
                    var helpDialogVisible by remember { mutableStateOf(false) }
                    Menu("帮助(H)", mnemonic = 'H') {
                        Item("帮助文档(H)", mnemonic = 'H', onClick = { helpDialogVisible = true })
                        Item("关于(A)", mnemonic = 'A', onClick = { aboutDialogVisible = true })
                        if (aboutDialogVisible) {
                            AboutDialog(
                                version = version,
                                close = { aboutDialogVisible = false }
                            )
                        }

                    }
                }
            }
        }
    }

}
okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.