VST3: macOS key forwarding
This commit is contained in:
parent
aa7697d7f2
commit
1321999aec
@ -48,7 +48,9 @@ public:
|
||||
|
||||
bool on_window_show(const std::string&);
|
||||
void on_window_hide ();
|
||||
void forward_key_event (GdkEventKey*);
|
||||
void grab_focus();
|
||||
bool non_gtk_gui() const { return true; }
|
||||
|
||||
private:
|
||||
void view_realized ();
|
||||
|
@ -219,6 +219,25 @@ VST3NSViewPluginUI::on_window_hide ()
|
||||
hide_all ();
|
||||
}
|
||||
|
||||
void
|
||||
VST3NSViewPluginUI::forward_key_event (GdkEventKey* ev)
|
||||
{
|
||||
/* despite the VST3 spec mandating onKeyUp/Down, many
|
||||
* plugins (notably JUCE) reply on platform callbacks.
|
||||
*/
|
||||
NSEvent* nsevent = gdk_quartz_event_get_nsevent ((GdkEvent*)ev);
|
||||
if (!nsevent) {
|
||||
return;
|
||||
}
|
||||
if ([nsevent type] == NSKeyDown) {
|
||||
[[[_ns_view window] firstResponder] keyDown:nsevent];
|
||||
} else if ([nsevent type] == NSKeyUp) {
|
||||
[[[_ns_view window] firstResponder] keyUp:nsevent];
|
||||
} else if ([nsevent type] == NSFlagsChanged) {
|
||||
[[[_ns_view window] firstResponder] flagsChanged:nsevent];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VST3NSViewPluginUI::grab_focus ()
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ VST3PluginUI::resizable ()
|
||||
bool
|
||||
VST3PluginUI::non_gtk_gui() const
|
||||
{
|
||||
// return true to enable forward_key_event
|
||||
/* return true to enable forward_key_event */
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -134,11 +134,14 @@ VST3PluginUI::parameter_update ()
|
||||
void
|
||||
VST3PluginUI::forward_key_event (GdkEventKey* ev)
|
||||
{
|
||||
#if 0
|
||||
/* NB VST3NSViewPluginUI overrides this */
|
||||
#if 0 // -> non_gtk_gui () -> true
|
||||
// TODO: map key-events
|
||||
IPlugView* view = _vst3->view ();
|
||||
switch (gdk_key->type) {
|
||||
case GDK_KEY_PRESS:
|
||||
/* key: unicode code of key
|
||||
/* onKeyDown (char16 key, int16 keyCode, int16 modifiers)
|
||||
* key: unicode code of key
|
||||
* keyCode: virtual keycode for non ascii keys - see VirtualKeyCodes in keycodes.h
|
||||
* modifiers : any combination of modifiers - see KeyModifier in keycodes.h
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user