How can I prevent a window from showing background colouring - macos

I have an application which pops up a NSTextView in its main window.
Under Yosemite this shows the main window background colouring, which is very distracting.
If users select Reduce transparency it works as before.
How can I prevent this view from showing background colouring?
The NSTextView uses addSubView to add itself to the enclosing view.
I have tried subclassing and returning opaque YES, but can't seem to find any way of preventing other views showing through.
I guess I could remove the existing views, but this seems a little drastic.
Any suggestions?

Related

Focus ring is not shown with programmatically created controls

I am working on some general dialogs for our content management system. Everything is written programmatically in Cocoa/Objective-C without using xib files.
Unfortunately the focus ring is never displayed, even though I can use TAB to move between the controls, and even though all controls are (or are inherited from) standard controls like NSButton, NSTextField and NSTextView.
On the other side, if I use xib files or storyboard files to make similar dialogs, the focus ring is shown without problems.
I expected that you only would need to draw the focus ring yourself if you are creating a custom view, which is directly inherited from NSView itself, regardless if you are using xib files or not.
Can anyone please help with this? Thank you very much in advance!

Strange behavior with accessory views on NSSavePanel and NSOpenPanel in sandboxed app

I have a problem with accessory views on NSSavePanel and NSOpenPanel.
Sometimes, (very often) when I open one of these panels the accessory view does not work (the view is shown but controls seem disabled).
I'm using this code to show the panel:
[openPanel beginSheetModalForWindow:appWindow completionHandler:openPanelHandler];
This only happens when app-sandbox is enabled.
After much testing I found out that what was happening was that the view was being misplaced (not attached to the panel).
When I open Mission Control and move the mouse pointer over the app windows I noticed that an "invisible" window hilighted and when select it I can take control over the accessory view (all controls work) but it appears detached from the open or save panel as shown on the screenshot.
I tried to create a new app just to test this behavior but was not able to reproduce it, so I suppose that has something to do with my app.
Any hint of what I may be doing wrong?
I don't want to code everything from scratch just to solve this issue.
Edit
Just a side note, when I close the window, just before the window close the accessory view flashes with the correct values for the controls. It appears that the application does not add the view in time for showing the panel.
Update 1
I subclassed the view that is used as accessory view and noticed that the
- (void)viewWillMoveToSuperview:(NSView *)newSuperview
is called, but
- (void)viewDidMoveToSuperview
never gets called even when the view is shown correctly, is this the normal behavior?
Update 2
I confirmed that - (void)viewDidMoveToSuperview should be called, on the test app both methods are called.
I also noticed a slight difference between my app and the test app. On my app the panel just slides down but on the test app the panel appears to "flip down" (don't know exactly how describe). The way the panel appears is irrelevant to me, I just noticed that it is not shown the same way.
After trying many things I concluded that the problem had to do with ARC (Automatic Reference Count) settings for the project.
In my case I had enabled ARC on target but not on project, after enabling ARC on project (and dealing with resulting errors and warnings) everything works perfectly now.

Flickering NSTextFields

I have two NSTextFields in a xib file I'm using to display some preferences to users.
There is a save button that I wanted to be unusable until these preferences have been filled out. For some reason, this made all the NSTextFields in the xib file totally unusable as well (it was as if they had been disabled).
When I enable the NSButton, everything works--but with a catch. Whenever I focus the cursor or type in one of the NSTextFields, the text inside flickers. It's really disconcerting.
There's no custom code powering the UI elements.
Any help is greatly appreciated.
It appears as though this is a bug in Interface Builder.
After deleting the NSTextFields that were flickering and adding them back in IB, the flickering stopped.

How to pass click on NSView through to app window beneath it?

My app has a NSView in a NSWindow which covers the screen and draws a semi-transparent shade on it, above that I've got another NSWindow which contains my app's UI, so the full screen view is designed to fade out background distraction of other windows.
How can I allow mouse clicks on the full screen view to go straight through to the underlying window, which will belong to another app, or even the desktop? Note that I don't want it to keep focus on my app.
Shady by Matt Gemmell does exactly the same, take a look at the source:
http://instinctivecode.com/shady/
It does this by sending the following message to the window:
[window setIgnoresMouseEvents:YES];

Interface-Builder outlets causing odd display behaviour

I've been working today on adding a sheet to the main window of my application. After having trouble seperating the two (main view/controller and sheet view/controller), I've gone with just having both views in the same xib and both controlled by the main controller. Now that it appears when the beginSheet method is called, I've designed the form, and hooked it up to the IBOutlets/Actions on my controller.
This is where the problem is. With no bindings between the forms objects and the controller, it displays perfectly. But when I connect buttons to IBActions, and text fields/imageviews to IBOutlets I encounter some weird display problems. I'm talking buttons not displaying (but the actions being executed when clicking where they should be), borders of NSBox's not showing and textfields not taking any typed text and displaying (still blank) further off the viewable area of the panel.
I discovered that I could rectify this by resizing the panel a little, but that's not usable. I did get it working fine with 3 textfields and 3 buttons and just close/minimize enabled (not that they actually seem to do anything to a sheet), but now I've hooked an imageview up to the controller and the one of the buttons isn't displaying again.
Is this something to do with the number of outlets/actions I'm using (The actual main window doesn't actually have any extra ones) or is it IB being buggy or me doing something very wrong?
My first suspicion would be that there is an exception being thrown somewhere during drawing the sheet. In my experience, that's usually the case when you get half-drawn controls like you're describing. Check the debugger console in Xcode to see if any error messages are being printed out there. You can also add a breakpoint on objc_exception_throw to have the debugger stop when an exception is thrown, that might shed further light on where exactly the problem is coming from.
This issue went away when I reconstructed the sheet from scratch. I do not know what caused the issue, but if anyone has a similar problem I would suggest trying to reconstruct it in a new sheet.

Resources