more focus fixes

This commit is contained in:
DBotThePony 2023-03-08 15:08:10 +07:00
parent dd74643c67
commit fc0bc69488
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 14 additions and 16 deletions

View File

@ -300,17 +300,12 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
*
* @param panel panel to be pushed up
*/
fun popup(panel: EditablePanel<MatteryScreen<*>>) {
fun popup(panel: EditablePanel<MatteryScreen<*>>): Boolean {
val indexOf = panels.indexOf(panel)
require(indexOf != -1) { "No such panel $panel" }
if (indexOf == 0) {
return
}
if (indexOf <= 0) return false
panels.removeAt(indexOf)
panels.addFirst(panel)
return true
}
/**

View File

@ -1185,6 +1185,10 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
var parent: EditablePanel<*>? = this
while (parent != null) {
if (parent.parent == null) {
parent.popup(false)
}
for (child in parent.childrenInternal) {
if (child !== filter) {
child.killFocus()
@ -1193,8 +1197,11 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
filter = parent
parent = parent.parent
parent?.killFocusThis(false)
parent?.hasFocusedChildren = true
if (parent != null) {
parent.killFocusThis(false)
parent.hasFocusedChildren = true
}
}
isFocusedThis = true
@ -1328,12 +1335,8 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
}
}
if (mouseClickedInner(x, y, button)) {
if (autoRequestFocus) requestFocus()
return true
}
return false
return mouseClickedInner(x, y, button)
}
fun mouseClickedChecked(x: Double, y: Double, button: Int): Boolean {