Skip to content

Commit

Permalink
#93 fix menu behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Tae Won Ha committed Nov 14, 2014
1 parent ffd2dd8 commit 0582ee0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions VimR/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@
<menuItem title="View" id="295">
<menu key="submenu" title="View" id="296">
<items>
<menuItem title="Focus File Browser" id="lxp-G4-8vM">
<modifierMask key="keyEquivalentModifierMask"/>
<menuItem title="Focus File Browser" keyEquivalent="0" id="lxp-G4-8vM">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="showFileBrowser:" target="-1" id="mYg-G3-1Wi"/>
<action selector="focusFileBrowser:" target="-1" id="nLp-Fl-zao"/>
</connections>
</menuItem>
<menuItem title="Focus Text Area" id="QxQ-g1-Bzs">
Expand Down
4 changes: 3 additions & 1 deletion VimR/TextMate/VRWorkspaceView.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ extern NSString *const qSidebarWidthAutosaveName;
- (IBAction)toggleSyncWorkspaceWithPwd:(NSMenuItem *)sender;
- (IBAction)toggleShowFoldersFirst:(NSMenuItem *)sender;
- (IBAction)toggleShowHiddenFiles:(NSMenuItem *)sender;
- (IBAction)hideSidebar:(id)sender;
- (IBAction)toggleSidebarOnRight:(id)sender;

- (IBAction)hideFileBrowser:(id)sender;
- (IBAction)focusFileBrowser:(id)sender;
- (IBAction)showFileBrowser:(id)sender;

@end
23 changes: 13 additions & 10 deletions VimR/TextMate/VRWorkspaceView.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,24 @@ - (IBAction)toggleStatusBar:(NSMenuItem *)sender {
self.needsUpdateConstraints = YES;
}

- (IBAction)hideSidebar:(id)sender {
self.fileBrowserView = nil;
[self.window makeFirstResponder:_vimView.textView];
}

- (IBAction)toggleSidebarOnRight:(id)sender {
self.fileBrowserOnRight = !_fileBrowserOnRight;
[self.mainWindowController forceRedrawVimView]; // Vim does not refresh the part in which the file browser was
}

- (IBAction)focusFileBrowser:(id)sender {
if (_fileBrowserView == nil) {
[self showFileBrowser:sender];
}

[self.window makeFirstResponder:_fileBrowserView.fileOutlineView];
}

- (IBAction)showFileBrowser:(id)sender {
if (_fileBrowserView) {
[self.window makeFirstResponder:_fileBrowserView.fileOutlineView];
self.fileBrowserView = nil;
[self.window makeFirstResponder:_vimView.textView];

return;
}

Expand Down Expand Up @@ -247,14 +252,12 @@ - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem {
if (_fileBrowserView == nil) {
[(NSMenuItem *) anItem setTitle:@"Show File Browser"];
} else {
if (self.window.firstResponder != _fileBrowserView) {
[(NSMenuItem *) anItem setTitle:@"Focus File Browser"];
}
[(NSMenuItem *) anItem setTitle:@"Hide File Browser"];
}
return YES;
}

if (action == @selector(hideSidebar:)) {return _fileBrowserView != nil;}
if (action == @selector(focusFileBrowser:)) {return YES;}

if (action == @selector(toggleStatusBar:)) {
if (_showStatusBar) {
Expand Down

0 comments on commit 0582ee0

Please sign in to comment.