You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/architecture.md
+18-14Lines changed: 18 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -525,21 +525,25 @@ It is possible to emulate the tmux-like keyboard prefix approach by using a glob
525
525
```xml
526
526
<config>
527
527
<events>
528
-
<applet><!-- Key bindings for the application window. -->
529
-
<if_mod_on="if (not kbmodifier) then return; end;"/><!-- `if_mod_on` macro definition. Do nothing if`kbmodifier` is false. -->
528
+
<desktop>
530
529
<script="kbmodifier = not kbmodifier; log('kbmodifier=', kbmodifier);" on="Ctrl+B"/><!-- Emulate tmux-like prefix key. The expression `log('kbmodifier=', kbmodifier);` is fordebugging purposes only (the output is visiblein the `Log Monitor`). -->
<script=if_mod_on | MoveAppletRight on="preview: RightArrow"/><!-- Use "preview:..." to get the key event before the terminal/application. -->
533
-
<script=if_mod_on | MoveAppletUp on="preview: UpArrow" /><!-- When kbmodifier is true, you can move windows using the arrow keys. -->
534
-
<script=if_mod_on | MoveAppletDown on="preview: DownArrow" /><!-- Macros like `MoveApplet...` are defined in the default configuration. You can list them with `vtm -l`. -->
535
-
<script=if_mod_on | MoveAppletTopLeft on="preview: LeftArrow+UpArrow | UpArrow+LeftArrow" /><!-- Simultaneous key presses should also be processed if supported. -->
536
-
<script=if_mod_on | MoveAppletBottomLeft on="preview: LeftArrow+DownArrow | DownArrow+LeftArrow" /><!-- It is convenient to specify multiple keyboard shortcuts in one definition separated by `|`. -->
<applet><!-- Key bindings for the application window. -->
532
+
<KeyFilter="if (not kbmodifier and vtm.gear.Bypass()) then return; end; "/><!-- `KeyFilter` macro. Do nothing if`kbmodifier` is false. Calling vtm.gear.Bypass() always returns true. -->
533
+
<script=KeyFilter | MoveAppletLeft prerun=KeyFilter on="LeftArrow" /><!-- The `|` operator concatenates script fragments/macros. If for some reason the keyboard event is not processed by anyone, it will thenreturn and fire on this object, so the KeyFilter is also reused at the beginning of the `script="..."`. -->
534
+
<script=KeyFilter | MoveAppletRight prerun=KeyFilter on="RightArrow" /><!-- The `prerun` attribute contains a Lua script that will be executed during pre-polling to filter out key events. -->
535
+
<script=KeyFilter | MoveAppletUp prerun=KeyFilter on="UpArrow" /><!-- When kbmodifier is true, you can move windows using the arrow keys. -->
536
+
<script=KeyFilter | MoveAppletDown prerun=KeyFilter on="DownArrow" /><!-- Macros like `MoveApplet...` are defined in the default configuration. You can list them with `vtm -l`. -->
537
+
<script=KeyFilter | MoveAppletTopLeft prerun=KeyFilter on="LeftArrow+UpArrow | UpArrow+LeftArrow" /><!-- Simultaneous key presses should also be processed if supported. -->
538
+
<script=KeyFilter | MoveAppletBottomLeft prerun=KeyFilter on="LeftArrow+DownArrow | DownArrow+LeftArrow" /><!-- It is convenient to specify multiple keyboard shortcuts in one definition separated by `|`. -->
@@ -416,6 +416,7 @@ Tag | Belongs to | Value | Description
416
416
`<dom_element>` | | ObjectID | Visual tree object id.
417
417
`id` | `<dom_element>` | UTF-8 string | Additional id for the visual tree object.
418
418
`script` | `<dom_element>` | UTF-8 string | A Lua script that will be executed when the events specified by the `on` tags occur.
419
+
`prerun` | `script` | UTF-8 string | A Lua script that will be executed during pre-polling prior the non-preview keyboard events specified in the `on` tags occurs. This is mostly used to indicate that the event is not expected on the source object.
419
420
`on` | `script` | EventID | Specific event id text string.
420
421
`source` | `on` | ObjectID | Visual tree object id.
421
422
@@ -594,6 +595,7 @@ Standard object names
594
595
| | | `vtm.gear.Interrupt()` | Interrupt the key event processing.
595
596
| | | `vtm.gear.RepeatWhilePressed(ref ObjectId)` | Capture the mouse by ObjectId and trigger the mouse button pressed event to repeat while pressed.
596
597
| | | `vtm.gear.Focus(ref ObjectId) -> bool` | Set input focus to the object. Returns true if focus is already set.
598
+
| | | `vtm.gate.Bypass() -> bool` | Indicates that the keyboard event being processed is not expected by this object. Used by the `prerun` function inside `script` to bypass tier::keybdrelease events. Always return true.
597
599
|`desktop` | Desktop environment | `vtm.desktop.Cleanup(bool b)` | Clean up temporary internal structures of the desktop environment and optionally report the state of registry objects.
598
600
| | | `vtm.desktop.EventList()` | Print all available generic event IDs.
599
601
| | | `vtm.desktop.Shutdown()` | Close all windows and shutdown the desktop.
`<script="..." on="KeyChord"/>` | Append existing bindings with the directly specified Lua script body.
676
+
`<script="..."><on="KeyChord" source="ObjectID"/></script>` | Binding to an event source using a specific `ObjectID`.
677
+
`<script="" on="KeyChord"/>` | Remove all existing bindings for the specified key combination `KeyChord`.
678
+
`<script="..." on="KeyChord" prerun="if (something) vtm.gear.Bypass() end"/>` | Bypass the `KeyChord` event if something. Works only with non-preview KeyChords.
679
+
`<script="..." on="" />` | Do nothing.
677
680
678
681
EventId's:
679
682
@@ -1143,7 +1146,7 @@ Notes
1143
1146
<script="vtm.defapp.ShowClosingPreview(faux);"on="Any" /> <!-- Preview for "Any" is always triggered after all other previews. Non-preview "Any" is triggered before all other keys. -->
1144
1147
<script="if (not vtm.gear.IsKeyRepeated()) then vtm.defapp.ShowClosingPreview(true); end"on="Esc" /> <!-- Window pred-close action (close when releasing the Esc key). -->
1145
1148
<script="if (vtm.defapp.ShowClosingPreview()) then vtm.defapp.Close() end"on="preview:-Esc"/> <!-- Close the window on Esc release. -->
1146
-
<script="if (vtm.defapp.ShowClosingPreview()) then local focus_count=vtm(); vtm.defapp.ShowClosingPreview(focus_count~=0) end"source="applet"on="release:e2::form::state::focus::count" /> <!-- Disable window closing preview when focus is lost. -->
1149
+
<script="if (vtm.defapp.ShowClosingPreview()) then local focus_count=vtm(); vtm.defapp.ShowClosingPreview(focus_count~=0) end"on="release:e2::form::state::focus::count" /> <!-- Disable window closing preview when focus is lost. -->
Copy file name to clipboardExpand all lines: src/netxs/desktopio/events.hpp
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ namespace netxs::events
42
42
staticconstexprauto mouserelease = __COUNTER__ - counter; // events: Run in subscription order for object tree.
43
43
staticconstexprauto keybdpreview = __COUNTER__ - counter; // events: Run in subscription order for focused objects.
44
44
staticconstexprauto keybdrelease = __COUNTER__ - counter; // events: Run in subscription order for focused objects.
45
+
staticconstexprauto keybd_prerun = __COUNTER__ - counter; // events: Run in subscription order for focused objects (fires during keybdpreview stage; subscribers can reset gear.touch if their current keybdrelease subscription is not confirmed).
auto [chords, is_preview] = input::bindings::get_chords(chord_str);
2209
2210
if (chords.size())
2210
2211
{
2211
2212
auto script_ptr = ptr::shared<script_ref>(boss.indexer, boss, script_body);
2213
+
auto prerun_ptr = prerun_body ? ptr::shared<script_ref>(boss.indexer, boss, prerun_body) : netxs::sptr<script_ref>{};
2212
2214
auto reset_handler = !(script_ptr->script_body_ptr && script_ptr->script_body_ptr->second.size());
2213
2215
for (auto& binary_chord : chords) if (binary_chord.size()) // Scripts always store their sensors at the boss side, since the lifetime of base::scripting_context depends on the boss.
2214
2216
{
@@ -2237,6 +2239,10 @@ namespace netxs::input
2237
2239
auto event_id = boss.indexer.get_kbchord_hint(binary_chord);
2238
2240
auto tier_id = is_preview ? tier::keybdpreview : tier::keybdrelease;
Copy file name to clipboardExpand all lines: src/vtm.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -376,7 +376,7 @@ R"==(
376
376
<script="vtm.defapp.ShowClosingPreview(faux);"on="Any" /> <!-- Preview for "Any" is always triggered after all other previews. Non-preview "Any" is triggered before all other keys. -->
377
377
<script="if (not vtm.gear.IsKeyRepeated()) then vtm.defapp.ShowClosingPreview(true); end"on="Esc" /> <!-- Window pred-close action (close when releasing the Esc key). -->
378
378
<script="if (vtm.defapp.ShowClosingPreview()) then vtm.defapp.Close() end"on="preview:-Esc"/> <!-- Close the window on Esc release. -->
379
-
<script="if (vtm.defapp.ShowClosingPreview()) then local focus_count=vtm(); vtm.defapp.ShowClosingPreview(focus_count~=0) end"source="applet"on="release:e2::form::state::focus::count" /> <!-- Disable window closing preview when focus is lost. -->
379
+
<script="if (vtm.defapp.ShowClosingPreview()) then local focus_count=vtm(); vtm.defapp.ShowClosingPreview(focus_count~=0) end"on="release:e2::form::state::focus::count" /> <!-- Disable window closing preview when focus is lost. -->
0 commit comments