johnno1962 / injectionforxcode

Runtime Code Injection for Objective-C & Swift
MIT License
6.55k stars 565 forks source link

How can I custom settings #103

Closed jb522185660 closed 7 years ago

jb522185660 commented 8 years ago

I want to custome set the "ctrl+=: to "F5",how can I do that

johnno1962 commented 8 years ago

You can only customise to ctrl-something without modifying the plugin source.

jb522185660 commented 8 years ago

How can I do that?

johnno1962 commented 8 years ago

The relevant code is below. Not sure how you’d set it to F5 though myself.

NSMenu *productMenu = [[[NSApp mainMenu] itemWithTitle:@"Product"] submenu];
if (productMenu) {
    [productMenu addItem:[NSMenuItem separatorItem]];

    struct { const char *item,  *key; SEL action; } items[] = {
        {"Injection Plugin", "", NULL},
        {"Inject Source", [currentShortcut UTF8String], @selector(injectSource:)}
    };

    for ( int i=0 ; i<sizeof items/sizeof items[0] ; i++ ) {
        menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:items[i].item]
                                              action:items[i].action
                                       keyEquivalent:[NSString stringWithUTF8String:items[i].key]];
        [menuItem setKeyEquivalentModifierMask:NSControlKeyMask];
        if ( i==0 )
            [subMenuItem = menuItem setSubmenu:self.subMenu];
        else
            [menuItem setTarget:self];
        [productMenu addItem:menuItem];
    }

    introItem.title = [NSString stringWithFormat:@"Injection v%s Intro", INJECTION_VERSION];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(workspaceDidChange:)
                                                 name:NSWindowDidBecomeKeyNotification object:nil];
}
else
    [self error:@"InInjectionPlugin: Could not locate Product Menu."];
johnno1962 commented 8 years ago

You might want to look at https://github.com/johnno1962/Refactorator/issues/4

jb522185660 commented 8 years ago

OK,thank you !

jb522185660 commented 8 years ago

And How can I hide the xcode right-top corner red 1?

johnno1962 commented 8 years ago

Remove this line: [self.docTile performSelectorOnMainThread:@selector(setBadgeLabel:) withObject:@"1" waitUntilDone:NO];