Question

I am trying to open a context menu on the mouseDown event of my NSView but the menu never appears. I think the could is good but I must be missing something.

Here i my view:

class MyCustomView < NSView
  attr_accessor :menu

  def initWithFrame(frame)
    super(frame)  
    return self
  end

  def mouseDown(event)
    puts "---"
    puts menu.class.to_s
    NSMenu.popUpContextMenu(menu, withEvent:event, forView:self)
    puts "---"
  end
end

And here is the output when I click:

---
NSMenu
---

Does anyone has an idea why the menu does not show? Thanks, Greg

Was it helpful?

Solution

I have been able to solve my problem by using NSPopupButton.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top