Implement spacebar for play/pause and enter for restart current track for the mini window, and implement left/right arrows for seeking forward and backward for both the mini window and the main window playlist view.

CQTexperiment
Christopher Snowhill 2018-09-26 20:30:02 -07:00
parent 2a5221da25
commit 39bc8df77c
4 changed files with 49 additions and 3 deletions

View File

@ -298,11 +298,11 @@
</subviews>
<nil key="backgroundColor"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="1516">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="1516">
<rect key="frame" x="-100" y="-100" width="683" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="1515">
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="1515">
<rect key="frame" x="85" y="17" width="15" height="68"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
@ -773,6 +773,7 @@
<string key="NSNullPlaceholder">Cog</string>
</dictionary>
</binding>
<outlet property="playbackController" destination="705" id="vo7-mK-yQe"/>
</connections>
</window>
<menu title="MainMenu" systemMenu="main" id="29" userLabel="MainMenu">

View File

@ -198,6 +198,14 @@
{
[playbackController play:self];
}
else if (modifiers == 0 && c == NSLeftArrowFunctionKey)
{
[playbackController eventSeekBackward:self];
}
else if (modifiers == 0 && c == NSRightArrowFunctionKey)
{
[playbackController eventSeekForward:self];
}
// Escape
else if (modifiers == 0 && c == 0x1b)
{

View File

@ -7,9 +7,10 @@
//
#import <Cocoa/Cocoa.h>
#import "PlaybackController.h"
@interface MiniWindow : NSWindow {
IBOutlet PlaybackController *playbackController;
}
@end

View File

@ -36,5 +36,41 @@
// Do nothing!
}
- (void)keyDown:(NSEvent *)e {
unsigned int modifiers = [e modifierFlags] & (NSCommandKeyMask | NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask);
NSString *characters = [e characters];
unichar c;
if ([characters length] != 1)
{
[super keyDown:e];
return;
}
c = [characters characterAtIndex:0];
if (modifiers == 0 && c == ' ')
{
[playbackController playPauseResume:self];
}
else if (modifiers == 0 && (c == NSEnterCharacter || c == NSCarriageReturnCharacter))
{
[playbackController play:self];
}
else if (modifiers == 0 && c == NSLeftArrowFunctionKey)
{
[playbackController eventSeekBackward:self];
}
else if (modifiers == 0 && c == NSRightArrowFunctionKey)
{
[playbackController eventSeekForward:self];
}
else
{
[super keyDown:e];
}
}
@end