Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int i=0;
- NSUInteger b;
- NSMenu *menu = [[NSMenu alloc]init];
- //get the number of object in the buttontab array
- b = [tabsArray count];
- for (i=0;i<b;i++)
- {
- WebViewController *button = [tabsArray objectAtIndex:i];
- //Create a menu and set the different items of the menu
- NSMenuItem *item = [[NSMenuItem alloc]init];
- [item setTarget:self];
- [item setTitle:[button.pageTitleTab stringValue]];
- [item setImage:[button.faviconTab image]];
- [item setTag:i];
- [item setAction:@selector(tabs:)];
- [item setEnabled:YES];
- [menu addItem:item];
- [item release];
- }
- //Draw the menu on a frame
- NSRect frame = [allTabsButton frame];
- NSPoint menuOrigin = [[allTabsButton superview] convertPoint:NSMakePoint(frame.origin.x, frame.origin.y+frame.size.height-25)
- toView:nil];
- NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown
- location:menuOrigin
- modifierFlags:NSLeftMouseDownMask // 0x100
- timestamp:0
- windowNumber:[[allTabsButton window] windowNumber]
- context:[[allTabsButton window] graphicsContext]
- eventNumber:0
- clickCount:1
- pressure:1];
- [NSMenu popUpContextMenu:menu withEvent:event forView:(NSButton *)sender];
- [menu release];
Add Comment
Please, Sign In to add comment