Preparing search index...

    Event object containing mouse interaction data.

    export class MouseEventPanel extends PanelPlugin {
    connections: any[];
    static descriptor() {
    const d = new Descriptor();
    d.id = 'com.docs.UiMouseEventExample';
    d.name = 'MouseEvent Example';
    d.defaultDockState = DockState.Detached;
    d.defaultSize = new Size(350, 250);
    return d;
    }
    constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
    super(pluginSystem, descriptor);
    this.connections = [];
    }
    createWidget(parent: Widget): Widget {
    const root = new Widget(parent);
    const layout = new BoxLayout();
    layout.setDirection(Direction.TopToBottom);
    layout.spacing = 8;
    root.layout = layout;

    const title = new Label(root);
    title.text = 'MouseEvent Demo';
    title.fontRole = FontRole.TitleBold;
    layout.addWidget(title);

    const info = new Label(root);
    info.text = 'Click anywhere in this panel to see mouse event data.';
    info.wordWrap = true;
    layout.addWidget(info);

    const clickArea = new Widget(root);
    clickArea.setMinimumHeight(100);
    clickArea.toolTip = 'Click here';
    layout.addWidget(clickArea);

    // MouseEvent is delivered via onMousePress signal
    this.connections.push(
    clickArea.onMousePress.connect((event: MouseEvent) => {
    const btnName = event.button === MouseButton.LeftButton ? 'Left'
    : event.button === MouseButton.RightButton ? 'Right'
    : 'Other';
    info.text = `Click: (${event.x}, ${event.y}) button=${btnName}`;
    event.accept();
    })
    );

    return root;
    }
    deinit(): void {
    this.connections.forEach((c: any) => c?.disconnect());
    this.connections = [];
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    button: MouseButton

    NEW

    buttons: MouseButton

    NEW

    globalX: number

    NEW

    globalY: number

    NEW

    modifiers: KeyboardModifier

    NEW

    x: number

    NEW

    y: number

    NEW

    Methods

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object refers to the same instance as the given object.

      Parameters

      Returns boolean