commonMain.io.nacular.doodle.deviceinput.ViewFinder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-jvm Show documentation
Show all versions of core-jvm Show documentation
A pure Kotlin, UI framework for the Web and Desktop
package io.nacular.doodle.deviceinput
import io.nacular.doodle.core.Display
import io.nacular.doodle.core.Internal
import io.nacular.doodle.core.View
import io.nacular.doodle.geometry.Point
/**
* Created by Nicholas Eddy on 3/12/19.
*/
@Internal
public interface ViewFinder {
public fun find(at: Point): View?
}
@Internal
public class ViewFinderImpl(private val display: Display): ViewFinder {
override fun find(at: Point): View? {
var newPoint = at
var view = display.child(at)?.takeIf { it.enabled }
while(view != null) {
newPoint = view.toLocal(newPoint, view.parent)
view = view.child_(at = newPoint)?.takeIf { it.enabled } ?: break
}
return view
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy