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 {
|
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||||
val window = windows.lastOrNull()
|
val window = windows.lastOrNull()
|
||||||
val result = window?.mouseClicked(Point(mouseX, mouseY), MouseButton.fromMC(button))
|
val result = window?.mouseClicked(Point(mouseX, mouseY), MouseButton.fromMC(button))
|
||||||
when (result) {
|
return if (result == true) {
|
||||||
true ->
|
|
||||||
RenderHelper.playSound(SoundEvents.UI_BUTTON_CLICK)
|
RenderHelper.playSound(SoundEvents.UI_BUTTON_CLICK)
|
||||||
false ->
|
true
|
||||||
if (windows.size > 1) {
|
} else {
|
||||||
removeWindow(windows.last())
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result == true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -195,6 +195,11 @@ class Window {
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
val pointInView = Point(point.x - view.frame.left, point.y - view.frame.top)
|
val pointInView = Point(point.x - view.frame.left, point.y - view.frame.top)
|
||||||
return view.mouseClicked(pointInView, mouseButton)
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue