This repository was archived by the owner on Aug 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Events
nbilyk edited this page Dec 21, 2020
·
3 revisions
Acorn UI uses standard JS Events. There are two ways to handle events. The first is via EventTarget.addEventListener.
And the second is via the Signals syntax sugar. Many JS events have extension methods that allow them to be observed on a component. For example to listen to the click Event, use the syntax:
import com.acornui.input.clicked
+button {
clicked.listen {
println("Clicked from the ${it.button} button.")
}
}Event signals have the benefits of:
- Being strongly typed.
- Can be used in binding expressions. (E.g.
bind(dataChanged or input) { ... }) -
listenreturns a handle for unsubscribing. - Can be part of an API.
The EventSignal options by default is to use the bubble phase, and to be a passive listener. To add an active listener, pass EventOptions like so:
import com.acornui.input.clicked
+button {
clicked.listen(EventOptions(isPassive = false)) {
println("Clicked from an active listener.")
}
}Copyright © 2020 Poly Forest, LLC
- Overview
-
Developer's Guide
- Getting Started
- CI
- Building Views
- Acorn UI Architecture
- Components
- Button
- Calendar
- ColorPicker ....
- Fonts
- Style Guide
- FAQ
- Roadmap
- Support