Skip to content

Instantly share code, notes, and snippets.

@ichitaso
Forked from r-plus/OpenCloudTabs+.xm
Created April 10, 2013 12:38
Show Gist options
  • Save ichitaso/5354245 to your computer and use it in GitHub Desktop.
Save ichitaso/5354245 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
static BOOL isActivatingFromLongPress;
%hook BrowserToolbar
- (void)_installGestureRecognizers
{
%orig;
id bookmarkButton = MSHookIvar<id>(self, "_bookmarksItem");
UILongPressGestureRecognizer *longGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressBookmarkButton:)];
[[bookmarkButton view] addGestureRecognizer:longGesture];
[longGesture release];
}
%new(v@:@)
- (void)longPressBookmarkButton:(UIGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateBegan) {
isActivatingFromLongPress = YES;
[BC toggleCloudTabsFromButtonBar];
}
}
%end
%hook CloudTabViewController
- (void)_done
{
if (isActivatingFromLongPress) {
isActivatingFromLongPress = NO;
return [self dismissViewControllerAnimated:YES completion:^{}];
}
%orig;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment