Guest User

Untitled

a guest
Oct 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. int i=0;
  2. NSUInteger b;
  3. NSMenu *menu = [[NSMenu alloc]init];
  4.  
  5. //get the number of object in the buttontab array
  6. b = [tabsArray count];
  7. for (i=0;i<b;i++)
  8. {
  9. WebViewController *button = [tabsArray objectAtIndex:i];
  10.  
  11. //Create a menu and set the different items of the menu
  12. NSMenuItem *item = [[NSMenuItem alloc]init];
  13. [item setTarget:self];
  14. [item setTitle:[button.pageTitleTab stringValue]];
  15. [item setImage:[button.faviconTab image]];
  16. [item setTag:i];
  17. [item setAction:@selector(tabs:)];
  18. [item setEnabled:YES];
  19. [menu addItem:item];
  20. [item release];
  21. }
  22.  
  23. //Draw the menu on a frame
  24. NSRect frame = [allTabsButton frame];
  25. NSPoint menuOrigin = [[allTabsButton superview] convertPoint:NSMakePoint(frame.origin.x, frame.origin.y+frame.size.height-25)
  26. toView:nil];
  27.  
  28. NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown
  29. location:menuOrigin
  30. modifierFlags:NSLeftMouseDownMask // 0x100
  31. timestamp:0
  32. windowNumber:[[allTabsButton window] windowNumber]
  33. context:[[allTabsButton window] graphicsContext]
  34. eventNumber:0
  35. clickCount:1
  36. pressure:1];
  37.  
  38. [NSMenu popUpContextMenu:menu withEvent:event forView:(NSButton *)sender];
  39.  
  40. [menu release];
Add Comment
Please, Sign In to add comment