LensStudio:Ui.MouseEvent
ClassEvent object containing mouse interaction data.
Index
Example
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 = [];
}
}
Extends
Properties
button
readonlybutton:MouseButton
NEW
buttons
readonlybuttons:MouseButton
NEW
globalX
readonlyglobalX:number
NEW
globalY
readonlyglobalY:number
NEW
modifiers
readonlymodifiers:KeyboardModifier
NEW
x
readonlyx:number
NEW
y
readonlyy:number
NEW
Methods
accept()
accept():
void
Marks the event as handled so it will not propagate further.
Returns
void
Inherited from
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
ignore()
ignore():
void
Marks the event as unhandled so it propagates to parent widgets.
Returns
void
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean