Change window dismissal behavior

This commit is contained in:
Shadowfacts 2019-06-27 19:15:12 -04:00
parent db06b454b1
commit c5280143b0
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 10 additions and 9 deletions

View File

@ -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
}
}

View File

@ -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
}