I am writing a MacRuby (objective-c) application that is basically a web browser that opens a specific website (mine) by default.
However, I don't want links to open in the WebView. I would rather they open in the user's default browser. Here is the code I have so far, but it doesn't seem to be calling the decidePolicyForNavigation
method.
framework "WebKit"
class AppDelegate
attr_accessor :window
def applicationDidFinishLaunching(notification)
load_web_view
end
def load_web_view
web_view = WebView.new
request = NSURLRequest.requestWithURL(NSURL.URLWithString("http://example.com"))
web_view.mainFrame.loadRequest(request)
window.contentView = web_view
web_view.frameLoadDelegate = self
web_view.setPolicyDelegate(self)
end
# this makes it so links open in the default browser
def webView(view, decidePolicyForNavigationAction:actionInformation, request:request, frame:frame, decisionListener:listener)
puts 'running nav policy'
listener.ignore
NSWorkspace.sharedWorkspace.openURL(request.URL)
end
end
What am I doing wrong?