LensStudio:Ui.ShortcutContext
EnumEnum specifying the scope in which a Shortcut is active.
Index
Enumeration Members
Example
// ShortcutContext: WidgetShortcut, WidgetWithChildrenShortcut, WindowShortcut, ApplicationShortcut.
// Pick the narrowest scope that fits — ApplicationShortcut wins focus from the rest of the app.
const root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
root.layout = layout;
const label = new Label(root);
label.text = 'Ctrl+1 (widget), Ctrl+2 (app)';
layout.addWidgetWithStretch(label, 0, 0);
const widgetSc = new Shortcut(root, 'Ctrl+1', ShortcutContext.WidgetShortcut);
const appSc = new Shortcut(root, 'Ctrl+2', ShortcutContext.ApplicationShortcut);
this.connections.push(widgetSc.onActivated.connect(() => { label.text = 'Widget scope (Ctrl+1)'; }));
this.connections.push(appSc.onActivated.connect(() => { label.text = 'App scope (Ctrl+2)'; }));
Enumeration Members
ApplicationShortcut
ApplicationShortcut:
number
Shortcut is active anywhere in the application.
WidgetShortcut
WidgetShortcut:
number
Shortcut is active only when the parent widget has focus.
WidgetWithChildrenShortcut
WidgetWithChildrenShortcut:
number
Shortcut is active when the parent widget or any of its children has focus.
WindowShortcut
WindowShortcut:
number
Shortcut is active when the parent widget's top-level window is active.