Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
more minor fixes and kdoc improvements, bump version for release
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jul 9, 2021
1 parent 92f9b69 commit 06808de
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ext {
}

group 'com.github.kwebio'
version '0.10.7'
version '0.10.8'

repositories {
mavenCentral()
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/kweb/html/BodyElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ import kweb.WebBrowser
/**
* Represents the `body` element of the in-browser Document Object Model, corresponding to
* the JavaScript [body](https://www.w3schools.com/tags/tag_body.asp) tag.
*
* @sample document_sample
*/
class BodyElement(webBrowser: WebBrowser, id: String) : Element(webBrowser, null, "body", id)
2 changes: 0 additions & 2 deletions src/main/kotlin/kweb/html/Document.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import kweb.util.random
* [document](https://www.w3schools.com/jsref/dom_obj_document.asp) object.
*
* Passed in as `doc` to the `buildPage` lambda of the [Kweb] constructor.
*
* @sample document_sample
*/
class Document(val receiver: WebBrowser) : EventGenerator<Document> {
fun getElementById(id: String) = Element(receiver, null, "return document.getElementById(\"$id\")", id = id)
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/kweb/html/events/EventGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import kotlinx.serialization.json.JsonElement
import kweb.WebBrowser
import java.util.*

/**
* Something that event listeners can be attached to, such as an [kweb.Element] or a [kweb.html.Document]
*/
interface EventGenerator<T> {
val browser: WebBrowser
fun addImmediateEventCode(eventName: String, jsCode: String)
Expand Down
63 changes: 50 additions & 13 deletions src/main/kotlin/kweb/html/events/events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,59 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull

/**
* Corresponds to a [JavaScript event](https://developer.mozilla.org/en-US/docs/Web/API/Event) object.
*/
@Serializable
data class Event(val type: String, val retrieved: JsonElement = JsonNull)
data class Event(
val type: String,
/** @see kweb.Element.on **/
val retrieved: JsonElement = JsonNull
)

/**
* Corresponds to a [JavaScript event](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) object.
*/
@Serializable
data class KeyboardEvent(val type: String, val detail: Long,
val key: String, val altKey: Boolean,
val ctrlKey: Boolean, val code: String,
val location: Int, val metaKey: Boolean,
val shiftKey: Boolean, val locale: String? = null,
val isComposing: Boolean, val retrieved: JsonElement = JsonNull)
data class KeyboardEvent(
val type: String,
val detail: Long,
val key: String,
val altKey: Boolean,
val ctrlKey: Boolean,
val code: String,
val location: Int,
val metaKey: Boolean,
val shiftKey: Boolean,
val locale: String? = null,
val isComposing: Boolean,
/** @see kweb.Element.on **/
val retrieved: JsonElement = JsonNull
)

/**
* Corresponds to a [JavaScript event](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) object.
*/
@Serializable
data class MouseEvent(val type: String, val detail: Long,
val altKey: Boolean, val button: Int, val buttons: Int,
val clientX: Int, val clientY: Int, val ctrlKey: Boolean,
val metaKey: Boolean, val movementX: Int, val movementY: Int,
val region: String? = null, val screenX: Int, val screenY: Int,
val shiftKey: Boolean, val x: Int = clientX, val y: Int = clientY, val retrieved: JsonElement = JsonNull)
data class MouseEvent(
val type: String,
val detail: Long,
val altKey: Boolean,
val button: Int,
val buttons: Int,
val clientX: Int,
val clientY: Int,
val ctrlKey: Boolean,
val metaKey: Boolean,
val movementX: Int,
val movementY: Int,
val region: String? = null,
val screenX: Int,
val screenY: Int,
val shiftKey: Boolean,
val x: Int = clientX,
val y: Int = clientY,
/** @see kweb.Element.on **/
val retrieved: JsonElement = JsonNull
)

0 comments on commit 06808de

Please sign in to comment.