Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
plugin_key_routing.hpp
Go to the documentation of this file.
1// plugin_key_routing.hpp — who consumes a key inside an embedded plugin editor.
2//
3// An embedded editor shares one keyboard with its DAW. The editor must consume
4// the keys it genuinely handles (⌘Z, ⌘A, a typed character, an open menu's
5// arrows) and hand back every key it does not, because the host owns transport
6// (Space), Musical Typing, and its own accelerator table. Getting the first
7// half right is easy and gets noticed immediately; getting the SECOND half
8// wrong is what users report as "the plugin killed my spacebar".
9//
10// The answer must come from the view tree, not from a list of keys someone
11// guessed at: `route_plugin_key` asks the overlay policy, then the focused
12// view, then the root's global hook, and reports `forward_to_host` only when
13// none of them claimed the key.
14//
15// This lives in core/view and takes no platform type, because the same
16// question is asked from three different format seams that share no code:
17// macOS `-keyDown:` / `-performKeyEquivalent:` (AU v2/v3 hosted NSView),
18// `IPlugView::onKeyDown` (VST3), and CLAP's GUI extension. Each seam speaks a
19// different consumed/not-consumed dialect; only the policy is shared.
20
21#pragma once
22
23#include <cstdint>
24
26
27namespace pulp::view {
28
29class View;
30
48
56 bool is_function_key = false;
65 bool offer_global_hook = false;
66};
67
97
106
116bool is_plugin_navigation_key(KeyCode key, std::uint16_t modifiers);
117
118} // namespace pulp::view
Definition view.hpp:73
Input event types with modifier keys and pointer IDs.
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
bool is_plugin_navigation_key(KeyCode key, std::uint16_t modifiers)
The bounded navigation set a non-text widget may borrow from the host.
View * plugin_key_focus(View &root)
The focused view under root, or nullptr.
PluginKeyDisposition route_plugin_key(View &root, const PluginKeyOffer &offer)
Resolve who consumes offer under root.
PluginKeyDisposition
What an embedded plugin editor should do with a key it has been offered.
Definition plugin_key_routing.hpp:32
@ consumed
A view or the root's global hook consumed the key outright.
Definition plugin_key_routing.hpp:39
@ forward_to_host
Nothing under the root claimed the key.
Definition plugin_key_routing.hpp:36
@ insert_as_text
A focused text field did not treat the key as a command, and the key is a plain printable candidate.
Definition plugin_key_routing.hpp:46
KeyCode
Definition input_events.hpp:35
Rich key event with key code, modifiers, and repeat state.
Definition input_events.hpp:193
Platform-supplied facts about the key that core/view cannot derive from a KeyEvent alone.
Definition plugin_key_routing.hpp:51
bool is_function_key
The key carries no printable character (a function key, or AppKit's 0xF700-0xF8FF private-use range).
Definition plugin_key_routing.hpp:56
bool offer_global_hook
Whether this call may offer the key to root.on_global_key.
Definition plugin_key_routing.hpp:65
KeyEvent key
Definition plugin_key_routing.hpp:52