InteractableElement

Subclasses of this are able to receive click and hover events inside of an ElementView. These subclasses must implement getInteractionPath and the individual instances must have a non-null onClick or onHoverChanged handler set. These events are dispatched to the "top"-most element in the tree that would be able to fire, which occludes other elements below it.

Only elements with a set handler occlude other elements (so it may sometimes be useful to set a handler that no-ops to mask off another element's touch). Additionally, click and hover occlusion are handled separately, so an element with a click handler but not a hover handler will not block hover events below it.

Note that the term "hover" is often different between platforms. The built-in ElementViews try to bridge this gap, and include both true hover (a mouse pointer over the element, un-pressed) as well as the press or drag state (a mouse pointer on the element, pressed; or, a touch) as hover states. This enables use of hover as a pre-selection indicator on mobile devices.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

This is a delicate API that exposes the raw attribute backing without any type safety. This is frequently used by the internals of Krayon, but is likely something you shouldn't use as a library consumer. That said, it's still exposed for the cases where it's necessary. When using this, be very careful not to clobber existing attributes.

Link copied to clipboard
Link copied to clipboard
var data: Any?
Link copied to clipboard
var kind: String?

Analogous to an HTML class, except you can only have one.

Link copied to clipboard
open var parent: Element?
Link copied to clipboard
abstract val tag: String

Functions

Link copied to clipboard
open fun <E : Element> appendChild(child: E): E
Link copied to clipboard
abstract fun draw(kanvas: Kanvas)
Link copied to clipboard
abstract fun getInteractionPath(): Path

The path used for hit detection.

Link copied to clipboard
open fun <E : Element> insertBefore(child: E, reference: Element?): E
Link copied to clipboard
fun matches(selector: ElementSelector<*>): Boolean
Link copied to clipboard
fun onClick(handler: ClickHandler<T>?)

Set the ClickHandler for this element.

Link copied to clipboard
fun onHoverChanged(handler: HoverHandler<T>?)

Set the HoverHandler for this element.

Link copied to clipboard
open fun <E : Element> query(selector: ElementSelector<E>): E?
Link copied to clipboard
open fun <E : Element> queryAll(selector: ElementSelector<E>): Sequence<E>
Link copied to clipboard
fun <E : Element> removeChild(child: E): E
Link copied to clipboard
open override fun toString(): String