From c4e2b129e2f5e86efcaac0f55e74a2af334d677b Mon Sep 17 00:00:00 2001 From: Commit-La-Grenouille Date: Sat, 18 Mar 2023 14:29:32 +0100 Subject: [PATCH] CLEAR ACTION: fixing bug that was pasting meaningless text when clearing all entries --- README.md | 2 +- Sources/MyStreamDeckPlugin.m | 11 +++++++++-- .../previews/2-states-relationship.png | Bin 3 files changed, 10 insertions(+), 3 deletions(-) rename preview.png => Sources/net.localhost.streamdeck.clipboard-buddy.sdPlugin/previews/2-states-relationship.png (100%) diff --git a/README.md b/README.md index 9e183d8..5507ebc 100755 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A Stream Deck plugin for Mac to have some clipboard entries handy (independently from clipboard always changing status). -![Stream Deck screenshot](preview.png) +![Stream Deck screenshot](Sources/net.localhost.streamdeck.clipboard-buddy.sdPlugin/previews/2-states-relationship.png) If you are on Windows, check [BarRaider](https://github.com/BarRaider)'s "Multi Clip" function available in his [Win Tools](https://github.com/BarRaider/streamdeck-wintools) plugin. diff --git a/Sources/MyStreamDeckPlugin.m b/Sources/MyStreamDeckPlugin.m index 263d91d..7a1ff4c 100755 --- a/Sources/MyStreamDeckPlugin.m +++ b/Sources/MyStreamDeckPlugin.m @@ -380,8 +380,10 @@ - (void)setupIfNeeded - (void)keyDownForAction:(NSString *)action withContext:(id)context withPayload:(NSDictionary *)payload forDevice:(NSString *)deviceID { - // Useful only when dealing with STORE_ACT actions but does not hurt for others - _keyPressed = [[NSDate alloc] init]; + // Useful only when dealing with STORE_ACT actions otherwise it would trigger a pasting on keyUpForAction + if([action isEqualToString:STORE_ACT]) { + _keyPressed = [[NSDate alloc] init]; + } if([action isEqualToString:NUKE_ACT]) { @@ -400,6 +402,11 @@ - (void)keyDownForAction:(NSString *)action withContext:(id)context withPayload: - (void)keyUpForAction:(NSString *)action withContext:(id)context withPayload:(NSDictionary *)payload forDevice:(NSString *)deviceID { + if([action isEqualToString:NUKE_ACT]) { + // We should do nothing + return; + } + _keyReleased = [[NSDate alloc]init]; NSTimeInterval diff = [_keyReleased timeIntervalSinceDate:_keyPressed]; diff --git a/preview.png b/Sources/net.localhost.streamdeck.clipboard-buddy.sdPlugin/previews/2-states-relationship.png similarity index 100% rename from preview.png rename to Sources/net.localhost.streamdeck.clipboard-buddy.sdPlugin/previews/2-states-relationship.png