Public API
onAnnotationOpened
Run a callback when the annotation editor opens.
Listen to annotation opening on this reader, including the normal KOReader view. No viewer or surface registration is required.
local stop = ink:onAnnotationOpened(function(event)
self.annotation_open = true
self.annotation_document = event.document
end)
-- When your plugin disconnects:
stop()Arguments
| Name | Type | Meaning |
|---|---|---|
callback | function | Called once after the editor is created and shown. Its return value is ignored. |
The callback receives {document = ui.document, surface = surface_or_nil}.
surface is nil for the normal reader and a surface table for an external viewer.
Returns
An unsubscribe() function. Call it when your owner closes. Calling it again is safe;
it takes no arguments and returns no value.
Things to know
- Subscribing does not replay a session already open. Navigation is not a new opening.
- A failed open or another open request for an already-shown editor emits no new event.
- Returning
falsecannot cancel opening. Listener errors are logged; other listeners still run. - The callback must be a function. Invalid arguments or subscribing after reader closure raise a Lua assertion.
See the event-only example for connection and cleanup.