Disable All Interaction with a Cocoa WebView - cocoa

I'm having difficulty in using a WebView that is being used purely to display a preview of a website - and I want to ignore all/any interactions the user may try to make with it.
I've already tried Cocoa webView - Disable all interaction to no avail; you can still easily spam-click and it will recognise the presses. (at least there's no context menu)
This one seems overkill; Disable a WebKit WebView - there must be an easier way.
In iOS I know exactly how to solve this, but as a Cocoa newcomer I am stumped - does anyone have any suggestions or better ways to achieve this? Or dump a transparent NSView on top and gobble up interactions? (tried this as well by subclassing an NSView, also to no effect)
Whole project is in IB currently, if this makes any difference.

I think you want to implement a WebPolicy Delegate and have it deny navigation events.

Related

Custom NSTabView with lefttab

I want to make a NSTabView like CleanMyMac or other application.
Never tried to customize NSOutlineView or NSTableView that heavily but I doubt it would get close enough to the custom (read: non-standard) behaviour you're looking for..
You can check for third party, Open Source controls that implement something similar. There are a couple of controls listed on Cocoa Controls that come pretty close.
Cocoa Controls is good idea.
Maybe this is a nice starting point:
https://github.com/monyschuk/LITabControl

Enable click-through without overriding NSView acceptsFirstMouse

The proper way of enabling click-though is to override acceptsFirstMouse on an NSView to return YES. (Click-through means that you can click on and use a control even when its window is not focused. For example, the Finder toolbar buttons, and the traffic-light window controls use this.)
My problem is that my application is not based on Cocoa, but GTK. Under the hood, GTK uses some Carbon and Cocoa, and I can get a pointer to the NSView if I want - but I can't get the widget to use a different NSView subclass without editing the GTK source. What are other ways to achive click-through?
(And, if possible, "hover-through" - I'd like to have mouse-over events on the click-through controls, too, so I can highlight them, telling the user that they are clickable.)
I could call Carbon's InstallWindowEventHandler with kEventWindowGetClickActivation, but I'm not sure how to use it, and if it's going to work (I've read Carbon is deprecated and might not work on modern Macs anymore). Alternatively, there must be a low-level mechanism to enable this (the Cocoa mechanism has to be implemented somehow). Any ideas?

How can I create an iOS-style toolbar in my Mac Cocoa application?

Several iLife '11 applications on the Mac use iOS-style black toolbars. For instance, the toolbar at the bottom of this screenshot of iPhoto:
(source: pocket-lint.com)
This sort of look is available in the iOS SDK as "UITabBar."
I am wondering if there is an easy way to achieve this in my ordinary, non-iOS Mac application. If not, what would be the best way to go about creating this effect?
There's nothing that will give you this view out of the box. You'll need to build it yourself.
The simplest method would be to create a custom view with a gradient background and place monochrome buttons in it.
Better would be to create a set of classes similar to NSToolBar that handle positioning, highlighting etc. Even better, build it and then open-source it :-)
However, you'll have to build it yourself. Apart from NSButton there's not much that will help in the pre-existing objects.

How to create a cocoa app windows like tweetie

I'm new to cocoa app dev, and I'm searching a solution to create a windows like the tweetie main windows with a left tool bar and a panel that point to the selected icon.
like this screenshot : http://i.stack.imgur.com/qvxWu.jpg
could anyone help me?
It's likely that a lot of the Tweetie UI is implemented using custom controls. You'll want to look into subclassing NSView and how to handle drawing and mouse events. There's nothing built into the Cocoa framework for this.
The NSView documentation has info on view programming, drawing, and event handling. If you're new to Cocoa, you may want to start off with something built in, though, as this will be a lot of work (and requires a pretty good understanding of how the framework works).

Mac OSX, Cocoa event model in NPAPI , NSView, and Out of process plugins

Well, currently chrome has out of process plugins. and firefox 4 will use same model.
That means plugin process is now seperated from browser process.
Plugin process might NOT have window at all.
My plugin is based on NSView.
Before cocoa event model, when I can access NSWindow in browser process, All I have to do is just add my_view as a subview of the contentView in the window.
[[the_window contentView] addSubview:my_view]
I do NOT need to process events myself. It worked itself.
But now, I convert NPCocoaEvents into NSEvents in event process code.
Do I have to change it myself?
Also some instance of NSEvents, I can not make them for example, wheel mouse events.
What should do I do?
Did I approach a wrong way?
Please enlighten me.
Do I have to change it myself?
If you plan to use the approach of forwarding NSEvents to your existing NSView then yes; there's no way to get access to the original NSEvents. They don't exist in the plugin process.
Another option would be to move away from trying to use native controls, and do your own drawing and event handling. This is the way most NPAPI plugins work.
A third possibility would be to open a separate window for your plugin content, and put your view in that window. This isn't technically supported by NPAPI, and it won't be perfect, but it might be a short-term way to get your plugin working while you explore long-term options.
Did I approach a wrong way?
Yes, what you were doing before was an unsupported hack, and not how NPAPI was intended to be used. Adding a view to a browser's window assumes things about the browser's view hierarchy that are implementation details, and subject to change at any time.
One option would be to use the FireBreath framework to create your plugin, as it already has a lot of the abstraction for negotiating the event and drawing models as well as an event abstraction. It's pretty straightforward to get up and going.

Resources