NSWindow color not changing if I am using it as NSSheet. How resolve this issue? - objective-c

I know it seems to be a trivial question however I am facing hard time to find a solution.
Please let me explain what I am doing.
How I am changing NSWindow background Color
I have generated a User defined runtime attributes Key backgroundColor of type Color for the NSWindow
Issue
The above way is working fine however when I am calling the NSWindow as NSSheet then the color of window is not changing.
Please suggest some solution for the issue. Many thanks.

This is happening because when an NSWindow is a sheet, It doesn't draw It's background color.
I think a solution to this would be to add a background view to your window and draw the background using this view instead of using the window's backgroundColor property.
Like this sample app.

Related

iOS / Titanium: Clear Button cannot be seen on a TextField with a black background

I want to add the clear button on the TextField like so:
<TextField clearButtonMode-"Titanium.UI.INPUT_BUTTONMODE_ALWAYS" backgroundColor="black"/>
The clear button usually looks like this:
However the issue is that the background of the TextInput is black. This means the clear button cannot be seen.
How can I change the appearance or colour of the clear button so this is not an issue?
I know that it should work but if its an ti sdk issue then you should try to test it with other ti sdks.
If you find same issue then you can file a JIRA issue with test app and then you can use rightButton property to achieve what you want.
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TextField-property-rightButton
To be completely honest man. you could just add a view inside the textField. I think its bit more efficient anyways and if you code by percentages as long as your border radius is more then half the height it will be circle.

Add / Remove buttons in NSOutlineView

I have a Source-View (NSOutlineView) with two Buttons at the bottom. I added an NSBox so that the items don't "shine through" when they're behind the buttons.
This works fine when the window is active:
But as soon as I deactivate the window the NSBox still has that active color, rather than a dimmed version to match the NSOutlineView's background color:
How can I make sure that those two colors always match. Also using a specific color is a bit of a hack since the color NSOutline uses might change at some point.
Update: Apple's Mail.app as well as Things seem to have a solution for that problem. :-/
#Neha put me on the right way to find a solution.
I write it in Ruby because I work with Rubymotion but it's easy to translate :)
Assuming you have a box outlet for the NSBox, you can set it to transparent when the window loses the focus and do the opposite when it becomes the key window, using the appropriate delegate methods:
def windowDidBecomeKey(notification)
box.setTransparent(false)
end
def windowDidResignKey(notification)
box.setTransparent(true)
end
And the result looks fine with the focus:
And without it:
The solution is to keep a reference to the NSOutlineView's backgroundColor property as it is a special NSColor that dynamically changes depending on the key status of the parent window. Set the color of your custom view to that that reference. When the window loses/gains key status, call setNeedsDisplay: on your custom view to redraw it using the new color. Use KVO to observe NSWindowDidBecomeKeyNotification and NSWindowDidResignKeyNotification. Note that pointer to the color stays the same, but the actual color represented by the reference changes. The solution is explained here.
In the attributes inspector of NSBox,
set display to transparent

Transparent NSWindow can only be grabbed where pixels are

I´m experimenting with custom NSWindow and got my first transparent custom window today.
Unfortunately I only can grab the window where pixels are visible. Is there a way to grab it anywhere inside the window bounds?
Tia, Ronald
How would the user know where the bounds are? Anyway, the solution is [theWindow setIgnoresMouseEvents:NO].

Transparent NSWindow but with standard border and shadow [duplicate]

This question already has an answer here:
Holes in NSView or NSWindow
(1 answer)
Closed 6 years ago.
I want to have a more or less standard NSWindow with a toolbar and all that, but I want the content view to be transparent so that I can see through it. At the same time I want to keep the light gray outline of the window and also it's shadow. BUT I want to avoid the "inner" shadow I get from the toolbar inside the content view area.
What I have tried so far is just to set the window background color to a semi transparent color and also set opaque to NO. The problem is that the window border fades away with the alpha of the background itself, and the more transparency I have on the background, the more the shadow of the toolbar shows up within the content view.
Generally, the window shadow and border changes depending on the transparency of the content view, which I totally understand. But I want a behavior where it keeps the border and shadow just as if it was a completely opaque window, and then I want the content view area to be transparent.
I am not sure what I need to do conceptually to make it work. Maybe I have to draw the window border myself, maybe not. Maybe I need to draw the shadow myself, or maybe not.
Is there anyone that know how to build this? I don't need exact code details, but rather what parts I need to do custom..
I appreciate any input!
I dont't know if this is of any value for you after all this time but try:
[aWindow setOpaque:NO];
[aWindow setBackgroundColor:[NSColor clearColor]];
Subclass the NSView class, override the drawRect:(NSRect)dirtyRect method and set the color of the view as clearcolor, now set the class of your content view as the Subclass of NSView.

How can I make a window or NSPanel out of an image?

I'm trying to add some style to my app and it's driving me crazy. I'm wanting to take a image that is transparent and use it as a window or NSPanel. I'm thinking this will have to be done programmatically but I would like to do it in Interface Builder. How can I achieve this effect either way. So far, I've tried both ways and can't achieve it. Any code examples would be much appreciated. Thanks
Make a borderless window, and set an image view as its content view, and set the image as the image view's image.