Regular Panel - Utility Panel

Hi

Is their any way using code that I can set a panel whose style is “Regular Panel” to “Utility Panel”?, if so could some one point me in the right direction please.

cheers

You probably want setStyleMask:.

thanks Shane

I looked up and found this in developer section

which I have tried to translate, and ended up with this, which fails at build time due to the ( ) around the number 1
where am I going wrong and how should it look to work correctly please.

script SET_STYLE_MASKAppDelegate
	property parent : class "NSObject"
    
    property MaskMain : missing value
    
    
    on awakeFromNib()
        
        MaskMain's setStyleMask_(1)--needs to either be regular or utility panel
    
    end awakeFromNib()
    
	
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened 
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
	
end script

cheers

What’s MaskMain?

MaskMain is the name of the panel, which is bound from the app delegate to the NSPanel

What do you mean by “at build time”? Are you getting a build error?

What makes you think that is the problem? I don’t see anything wrong with what you are doing, your syntax is correct. When I tried your code, it worked fine. However, the correct number to get a utility panel is 31 not 1 (to get the same utility panel you get in IB).

Ric

ok, that’s good to no, when compiling in xcode, the build fail with exit code says it’s because of “(” so this led me to think it was the way I had written it, ill go back and have another play, thanks for checking that out for me

Hello Budgie,

it’s because of your on awakeFromNib(), which should be:

on awakeFromNib_() -- with underscore.

Regards,

Not really – no argument means no underscore.

Shane,

its for the line end awakeFromNib() :

test/testAppDelegate.applescript:19: error: Expected end of line, etc. but found “(”. (-2741)

Good catch Bernard. This kind of error can be avoided by just typing “end” at the end of your methods – the editor will fill in the rest (at least in XCode 3, I don’t know if this is true in XCode 4).

Ric

great catch compiles fine now, but the NSPanel still doesnt want to stay front most as in the Utility Panel, which is what I am trying to Achieve.

rdelmar
Where do I find out about the number 31?

It’s not true in Xcode 4, alas. The compiler will handle it fine so your app will run, but what you see on screen is basically what you type. Very disappointing…

I found that out by choosing the Utility Panel option in IB when I created the panel, and then in code I added the line: log MaskMain’s styleMask(). It returned 31. 31 is the combination of the titled (1), closable (2), miniaturizable (4), resizable (8) and the NSUtilityWindowMask (16) choices. The last one is in the NSPanel Class reference and the rest are in the NSWindow Class reference.

I’m not sure why you’re not getting the floating panel behavior – using 31 should get you that according to the docs. Maybe try adding the line “MaskMain’s setFloatingPanel_(1)” and see if that makes any difference.

Ric

After Edit: What do you mean by “the NSPanel still doesnt want to stay front most as in the Utility Panel” ?
Does it not stay in front of other window’s in your app or of other open windows on your desktop? I do get mine to stay in front of any other windows in my app, but not of windows that I click on in other apps.

Hi,

NSPanel has floatingPanel / setFloatingPanel: methods

rdelmar

thanks for the info.

It does not stay in front of windows that I click on in other apps (which is what I need), where as If I set a panel whose style is “Regular Panel” to “Utility Panel”? in IB it does stay front most for all application windows.

I found that if I have the following 2 lines, I get a panel that always stays on top no matter what kind of panel it is.

MaskMain's setFloatingPanel_(1)
		MaskMain's setHidesOnDeactivate_(0)

Ric

that’s a beautiful thing Ric , thanks for helping out

:smiley: