문제

가 openGL GUI 인터페이스와 필요가 있는 팝업 메뉴가 호출될 경우 이는 특정 버튼을 누를 때에 내 openGL 표시됩니다.내가 원하는 메뉴를 표시합니와 유사한 팝업을 누를 때는 NSPopUPButton 만 사용할 수 없습니다 코코아 버튼을 자체입니다.그것은 보인다는 가장 좋은 방법은 이를 수행하는 사용 NSPopupButtonCell.수 게시물 내 코드기 때문에 여기에 내가 쓰는 코드에서는 Lisp 과에 액세스하는 코코아를 통해 목표 C 브리지 하지만 나는 그냥 보고 싶다면 다음과 같은 pseduo 코드 같은 것이 표시 메뉴가 있는 경우 분명한 결함 나의 논리:

• Pseudo Code for function that is called when button is pressed:
• Initialize an NSPopUpButtonCell Using initTextCell: "test" pullsDown: NO
• allocate an NSMenu using alloc
• add two menu items using addItem:
• set the menu of the popUpButtonCell to be the menu that was just allocated using setMenu:
• Next I tried two methods to try and get the menu to actually be displayed,
  first I tried using drawWithFrame:inView: and when that did not work I also tried 
  using drawBezelWithFrame:inView: eventhough the docs said not to use but I just 
  tried it out of desperation.
• finally, when the draw methods did not work I tried using performClick: on the 
  popupButtonCell to try and simulate the click.

아무도 이러한 방법의 성공에서 얻는 모든 종류의 메뉴 표시할 수 있습니다.은 거기에 몇 가지 다른 방법을 programtically 팝업 메뉴에 포함된 휴?

도움이 되었습니까?

해결책

나는 당신이 찾고 있다고 생각합니다 trackMouse:inRect:ofView:untilMouseUp: 의 방법 NSCell

[theCell trackMouse:[NSApp currentEvent] inRect:NSZeroRect ofView:theView untilMouseUp:YES];

다른 팁

나는 당신이 더 나을 것을 사용하여 일반 NSMenu 와 전화 +[NSMenu popUpContextMenu:withEvent:forView:].만약 당신이 타겟으로만 10.6 고 나중에,당신은 또한 체크 아웃 -[NSMenu popUpMenuPositioningItem:atLocation:inView:], 을 제공하는,당신은 좀 더 많은 제어의 위치는 메뉴입니다.그냥 구현 mouseDown: 에서 보기 구성 메뉴(또는 부하에서 펜촉 파일),그리고 표시 NSMenu 주의해야에서 모든 정보가 있다.그냥 있는지 확인 대상 및 작업에 대한 각 NSMenuItem 이 설정하도록 조치 방법을 가져오라고 올바르게 항목을 선택한 경우.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top