mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Handle paste, copy, cut events which come from plug-in hosts
This commit is contained in:
parent
1f303d674d
commit
9510c16665
3 changed files with 25 additions and 4 deletions
|
|
@ -661,6 +661,10 @@ public:
|
|||
(void) ev;
|
||||
}
|
||||
|
||||
void redirectCopy (NSObject*) { handleKeyPress (KeyPress ('c', ModifierKeys (ModifierKeys::commandModifier), 'c')); }
|
||||
void redirectPaste (NSObject*) { handleKeyPress (KeyPress ('v', ModifierKeys (ModifierKeys::commandModifier), 'v')); }
|
||||
void redirectCut (NSObject*) { handleKeyPress (KeyPress ('x', ModifierKeys (ModifierKeys::commandModifier), 'x')); }
|
||||
|
||||
void sendMouseEvent (NSEvent* ev)
|
||||
{
|
||||
updateModifiers (ev);
|
||||
|
|
@ -1458,6 +1462,10 @@ struct JuceNSViewClass : public ObjCClass <NSView>
|
|||
addMethod (@selector (performDragOperation:), performDragOperation, "c@:@");
|
||||
addMethod (@selector (concludeDragOperation:), concludeDragOperation, "v@:@");
|
||||
|
||||
addMethod (@selector (paste:), paste, "v@:@");
|
||||
addMethod (@selector (copy:), copy, "v@:@");
|
||||
addMethod (@selector (cut:), cut, "v@:@");
|
||||
|
||||
addProtocol (@protocol (NSTextInput));
|
||||
|
||||
registerClass();
|
||||
|
|
@ -1503,6 +1511,9 @@ private:
|
|||
static void mouseExited (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseExit (ev); }
|
||||
static void scrollWheel (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseWheel (ev); }
|
||||
static void magnify (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMagnify (ev); }
|
||||
static void copy (id self, SEL, NSObject* s) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectCopy (s); }
|
||||
static void paste (id self, SEL, NSObject* s) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectPaste (s); }
|
||||
static void cut (id self, SEL, NSObject* s) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectCut (s); }
|
||||
|
||||
static BOOL acceptsFirstMouse (id, SEL, NSEvent*) { return YES; }
|
||||
|
||||
|
|
|
|||
|
|
@ -177,11 +177,16 @@ Component* ComponentPeer::getTargetForKeyPress()
|
|||
bool ComponentPeer::handleKeyPress (const int keyCode, const juce_wchar textCharacter)
|
||||
{
|
||||
ModifierKeys::updateCurrentModifiers();
|
||||
bool keyWasUsed = false;
|
||||
|
||||
const KeyPress keyInfo (keyCode,
|
||||
ModifierKeys::getCurrentModifiers().withoutMouseButtons(),
|
||||
textCharacter);
|
||||
return handleKeyPress (KeyPress (keyCode,
|
||||
ModifierKeys::getCurrentModifiers().withoutMouseButtons(),
|
||||
textCharacter));
|
||||
}
|
||||
|
||||
|
||||
bool ComponentPeer::handleKeyPress (const KeyPress& keyInfo)
|
||||
{
|
||||
bool keyWasUsed = false;
|
||||
|
||||
for (Component* target = getTargetForKeyPress(); target != nullptr; target = target->getParentComponent())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -269,6 +269,11 @@ public:
|
|||
*/
|
||||
bool handleKeyPress (int keyCode, juce_wchar textCharacter);
|
||||
|
||||
/** Called when a key is pressed.
|
||||
Returns true if the keystroke was used.
|
||||
*/
|
||||
bool handleKeyPress (const KeyPress& key);
|
||||
|
||||
/** Called whenever a key is pressed or released.
|
||||
Returns true if the keystroke was used.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue