File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
common/src/main/kotlin/com/lambda/newgui Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ open class Layout(
6161 }
6262
6363 private var owningRenderer = false
64- protected open val passInteractions = false
64+ protected open val interactionPassthrough = false
6565
6666 // Actions
6767 private var showActions = mutableListOf< () -> Unit > ()
@@ -165,16 +165,18 @@ open class Layout(
165165
166166 fun onEvent (e : GuiEvent ) {
167167 // Select an element that's on foreground
168- selectedChild = if (mousePosition in rect ) children.lastOrNull {
169- ! it.passInteractions && mousePosition in it.rect
168+ selectedChild = if (isHovered ) children.lastOrNull {
169+ ! it.interactionPassthrough && mousePosition in it.rect
170170 } else null
171171
172172 // Update children
173173 children.forEach { child ->
174174 if (e is GuiEvent .Render ) return @forEach
175175
176176 if (e is GuiEvent .MouseClick ) {
177- val newAction = if (child == selectedChild || (child.passInteractions)) e.action else Mouse .Action .Release
177+ val hovered = child == selectedChild || (child.isHovered && child.interactionPassthrough)
178+ val newAction = if (hovered) e.action else Mouse .Action .Release
179+
178180 val newEvent = GuiEvent .MouseClick (e.button, newAction, e.mouse)
179181 child.onEvent(newEvent)
180182 return @forEach
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class TextField(
2626 var offset = initialOffset
2727
2828 // Let user interact through the text
29- override val passInteractions = true
29+ override val interactionPassthrough = true
3030
3131 init {
3232 rect {
You can’t perform that action at this time.
0 commit comments