Re: refresh window's background/mask
Re: refresh window's background/mask
- Subject: Re: refresh window's background/mask
- From: Craig Hunter <email@hidden>
- Date: Sat, 23 Apr 2005 16:30:04 -0400
>
> On Apr 23, 2005, at 12:28 PM, Craig Hunter wrote:
>
>> I have a transparent window in my app, and I want to be able to turn
>> the
>> transparency on/off with a checkbox. I am able to do that for the most
>> part. If the window starts out as transparent, I can toggle back and
>> forth
>> between transparent and opaque no problem. If the window starts out
>> opaque,
>> toggling back and forth between opaque and transparent has no visible
>> effect
>> unless I first hide/show the window manually in a transparent state. I
>> believe it's an issue with the window's mask.
>>
>> I am calling a window update whenever the mode is changed, which is
>> definitely required to have any effect. But nothing I have tried
>> forces the
>> background/mask to refresh when the window starts out opaque. Any
>> ideas?
>>
>
> Can you always just start out with the window as not opaque (i.e.,
> [window setOpaque: NO]) and then just change the background color
> according to what you need (so [window setBackgroundColor: [NSColor
> clearColor]] to make it transparent, [window setBackgroundColor:
> [NSColor whiteColor]] to make it non-transparent)?
That will work, and it's the best approach so far. One complication is that
my app checks prefs as it finishes launching and may set the window back to
opaque depending on the user's setting. Once it's set to opaque and the app
is officially "launched", the mask gets stuck and the user won't see an
effect of the transparent window checkbox in the prefs panel (they won't
necessarily be using it a lot, but it should not act broken!). It seems to
be a matter of event timing -- if I could launch with a transparent window,
check prefs, finish launching, and then set the window style some time later
after launch, it would be OK (I can do that sequence manually and it's OK).
I am doing this in an AppleScript Studio app, by the way (calling Obj-C to
set window attributes), so the prefs reading and window setting take place
in a "will finished launching" event handler (probably ties into an
analogous notification on the Obj-C side). That also seems to be the place
in time where the app is setting up it's window mask on the Cocoa side.
> In theory, a non opaque window with a solid (no alpha) background
> should appear the same as the opaque window.
>
> You'll also want to call [window invalidateShadow] to make sure the
> shadow (if you have one) is correct between those changes as well...
Yeah, I stumbled across that, pretty cool, and it has a small but noticeable
effect.
thanks!
Craig
--
Dr. Craig A. Hunter
NASA Langley Research Center
AAAC / Configuration Aerodynamics Branch
(757) 864-3020
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden