Change window dismissal behavior
This commit is contained in:
parent
db06b454b1
commit
c5280143b0
|
@ -72,16 +72,12 @@ open class CacaoScreen: Screen(TextComponent("CacaoScreen")) {
|
|||
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||
val window = windows.lastOrNull()
|
||||
val result = window?.mouseClicked(Point(mouseX, mouseY), MouseButton.fromMC(button))
|
||||
when (result) {
|
||||
true ->
|
||||
RenderHelper.playSound(SoundEvents.UI_BUTTON_CLICK)
|
||||
false ->
|
||||
if (windows.size > 1) {
|
||||
removeWindow(windows.last())
|
||||
}
|
||||
return if (result == true) {
|
||||
RenderHelper.playSound(SoundEvents.UI_BUTTON_CLICK)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
return result == true
|
||||
}
|
||||
|
||||
}
|
|
@ -195,6 +195,11 @@ class Window {
|
|||
if (view != null) {
|
||||
val pointInView = Point(point.x - view.frame.left, point.y - view.frame.top)
|
||||
return view.mouseClicked(pointInView, mouseButton)
|
||||
} else {
|
||||
// remove the window from the screen when the mouse clicks outside the window and this is not the primary window
|
||||
if (screen.windows.size > 1) {
|
||||
removeFromScreen()
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue