Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.supernote.com/llms.txt

Use this file to discover all available pages before exploring further.

registerMotionListener(
  registerType: number,
  listener: PluginEventListener
): PluginEventSubscription;
Parameters
ParameterTypeDescription
registerTypenumberRegistration priority: 0 always first, 1 normal order, 2 always last
listenerPluginEventListenerEvent callback object that implements onMsg(msg). Internally, this method is equivalent to registering a motion_event touch move event listener. The callback msg is MotionEvent
Returns
  • PluginEventSubscription: subscription object. Calling remove() unregisters the listener and removes the local subscription.

Example

import { PluginManager, type MotionEvent } from 'sn-plugin-lib';

/**
 * Example: register a touch move event listener.
 */
export async function exampleRegisterMotionListener() {
  const sub = PluginManager.registerMotionListener(1, {
    onMsg(msg) {
      const motion = msg as MotionEvent;
      console.log('touch move pointer count:', motion.pointerCount);
      console.log('first pointer id:', motion.pointers[0]?.pointerId);
    },
  });
  return sub;
}