Skip to content
Kunkun

Event

Docs: https://docs.api.kunkun.sh/interfaces/ui.IEvent

Event API contains commands to listen to some window/app events.

For more details, refer to Docs.

Sample Code

import { event } from '@kksh/api/ui/worker'
// or
import { event } from '@kksh/api/ui/iframe'
event.onDragDrop((payload) => {
const filePaths = payload.paths
const { x, y } = payload.position
})
event.onWindowFocus(() => {
document.getElementById("search-bar")?.focus()
})
event.onWindowBlur(() => {
// e.g. disconnect from server
})

Permission

  • onDragDrop: [ event:drag-drop ]
  • onDragEnter: [ event:drag-enter ]
  • onDragLeave: [ event:drag-leave ]
  • onDragOver: [ event:drag-over ]
  • onWindowBlur: [ event:window-blur ]
  • onWindowCloseRequested: [ event:window-close-requested ]
  • onWindowFocus: [ event:window-focus ]