compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

MenuBar not visible in 1.0.0-beta5

Open Adiudiu opened this issue 3 years ago • 6 comments

When I switch tabs dynamically and switch to a Swing control in a SwingPanel, MenuBar doesn't show up, it needs to manually resize the window to show up.

How to solve this problem? What are the alternative methods?

QQ截图20211126163012

Adiudiu avatar Nov 26 '21 08:11 Adiudiu

Could you share some small reproducer to this issue?

Also you could try version 1.0.0, that has been released recently - it contains quite a few bugfixes, so this issue could've also been fixed.

akurasov avatar Dec 08 '21 09:12 akurasov

I tried version 1.0.0 and still have problems.

Adiudiu avatar Dec 08 '21 12:12 Adiudiu

You can reproduce the problem with the official Demo -widgets- Gallery.

You need to make 4 changes to the Demo.

  1. Modify main.kt QQ截图20211208204603

MenuBar { Menu("File", mnemonic = 'F') { Item("New", onClick = { }) Item("Open", onClick = { }) Item("Import", onClick = { }) } }

  1. Modify Chips.kt QQ截图20211208204642

ComboBox("", 0, mutableListOf("1", "2"), onItemSelected = { print("lihj, ComboBox $it") })

3.Add file ComboBox.kt in Common lib QQ截图20211208210539

@Composable expect fun ComboBox( title: String?, selectIndex: Int? = 0, items: MutableList<String>, onItemSelected: (String) -> Unit )

4.Add class ComboBox.kt in desktop platform QQ截图20211208204725

`@Composable actual fun ComboBox( title: String?, selectIndex: Int?, items: MutableList<String>, onItemSelected: (String) -> Unit ) { Row(modifier = Modifier .fillMaxWidth() .wrapContentHeight() .padding(0.dp, 8.dp, 0.dp, 0.dp), verticalAlignment = Alignment.Top, horizontalArrangement = Arrangement.Center) { title?.let { Text(text = title, fontSize = 14.sp, modifier = Modifier.padding(0.dp, 6.dp, 0.dp, 0.dp)) } SwingPanel( background = Color.White, modifier = Modifier .size(100.dp, 30.dp), factory = { JPanel().apply { background = JColor.WHITE // add(JComboBox(items.toTypedArray()).apply { // selectedIndex = selectIndex ?: 0 // addItemListener { // if (it.stateChange == ItemEvent.SELECTED) { // onItemSelected.invoke(it.item as String) // } // } // }) val value = SpinnerNumberModel(5,0,10,1) layout = BoxLayout(this, BoxLayout.Y_AXIS) .apply {

                        val spinner = JSpinner(value).apply {
                            setBounds(0,0,50,30)
                        }
                        add(spinner)
                    }
            }
        }
    )
}

}`

Adiudiu avatar Dec 08 '21 13:12 Adiudiu

I tried with 1.0.0 on Mac (only added MenuBar itself as other changes doesn't seem related to it). What is your OS?

akurasov avatar Jan 11 '22 10:01 akurasov

I tried with 1.0.0 on Mac (only added MenuBar itself as other changes doesn't seem related to it). What is your OS?

I use Windows 10 Professional.

I guess this has something to do with Swing showing the hide on the Compose UI.

Adiudiu avatar Jan 16 '22 14:01 Adiudiu

I also got the same problem frequently. The menu is not visible until windows got resized. Calling window.invalidate() does not hepl too.

gregbarski avatar Feb 07 '24 08:02 gregbarski

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

okushnikov avatar Jul 14 '24 15:07 okushnikov