M.C. Escher
03/29/2024, 2:49 PMNick
03/29/2024, 2:56 PMbutton.pointerChanged += pressed {
// ...
if (Button2 in it.buttons) {
// consume should prevent the context menu
it.consume()
}
}
M.C. Escher
03/29/2024, 2:57 PMM.C. Escher
03/29/2024, 3:01 PMif (Button2 in it.buttons) {
it.consume()
val popupLocation = it.location
launch(uiDispatcher) {
modal.invoke {
val popup = menu(...)
pointerOutsideModalChanged += PointerListener.clicked { completed(Unit) }
ModalManager.Modal(popup) { modal ->
(<http://modal.top|modal.top> eq popupLocation.y)..Strong
(modal.left eq popupLocation.x)..Strong
}
}
}
}
I'd like to show the popup at the mouse cursor's location. This code works when I use the JVM runner, however in the browser the popup is not shown. Any idea what I'm doing wrong?
M.C. Escher
03/29/2024, 3:02 PMNick
03/29/2024, 3:03 PMM.C. Escher
03/29/2024, 3:03 PMNick
03/29/2024, 3:06 PMNick
03/29/2024, 3:10 PMM.C. Escher
03/29/2024, 3:14 PMpopup.size = Size(w,h)
doesn't seem to have an effectNick
03/29/2024, 3:18 PMMenuBehavior
installed and be using a Theme
. maybe you’re doing this for desktop but not web?Nick
03/29/2024, 3:18 PMM.C. Escher
03/29/2024, 3:19 PMM.C. Escher
03/29/2024, 3:22 PMallowPointerThrough = true
and right click a second time on my element, then it pops up a second menu, the first menu does not go away. any idea how to fix this?Nick
03/29/2024, 3:25 PMpointerOutsideChanged
is using a click which won’t happen b/c the pressed is consumed (press happens before click, which happens after press then release). so add a pressed listener to pointerOutsideChanged
as well that will dismiss the modal.M.C. Escher
03/29/2024, 3:26 PM