Page 1 of 1
Window on top of the StatusBar?
Posted: Sun Jan 10, 2016 6:35 pm
by deseven
Hello.
I wrote this code as an example, but can't figure out how to override screen boundaries:
Code: Select all
ExamineDesktops()
CreateImage(0,DesktopWidth(0),22,32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,DesktopWidth(0),22,RGBA(213,74,102,100))
StopDrawing()
OpenWindow(0,0,0,DesktopWidth(0),22,"test",#PB_Window_BorderLess)
CocoaMessage(0,WindowID(0),"setLevel:",20)
CocoaMessage(0,WindowID(0),"setOpaque:",#NO)
CocoaMessage(0,WindowID(0),"setBackgroundColor:",CocoaMessage(0,0,"NSColor colorWithPatternImage:",ImageID(0)))
CocoaMessage(0,WindowID(0),"setMovableByWindowBackground:",#NO)
CocoaMessage(0,WindowID(0),"setHasShadow:",#NO)
CocoaMessage(0,WindowID(0),"setIgnoresMouseEvents:",#YES)
Repeat
Delay(10)
i + 3
ResizeWindow(0,-i,0,#PB_Ignore,#PB_Ignore)
WindowEvent()
If i = DesktopWidth(0) : Break : EndIf
Until ev = #PB_Event_CloseWindow
Can someone port
this solution to PB?
Re: Window on top of the StatusBar?
Posted: Mon Jan 11, 2016 8:33 am
by Danilo
Looks like you have to use at least 24 for setLevel on El Capitan.
Re: Window on top of the StatusBar?
Posted: Mon Jan 11, 2016 9:01 am
by deseven
It works! Thanks!
Where did you find that constant?
Re: Window on top of the StatusBar?
Posted: Mon Jan 11, 2016 11:08 am
by Danilo
deseven wrote:Where did you find that constant?
Trial & Error.
The correct method:
Code: Select all
Import ""
CGWindowLevelForKey(key)
EndImport
Enumeration CGCommonWindowLevelKey
#kCGBaseWindowLevelKey = 0
#kCGMinimumWindowLevelKey
#kCGDesktopWindowLevelKey
#kCGBackstopMenuLevelKey
#kCGNormalWindowLevelKey
#kCGFloatingWindowLevelKey
#kCGTornOffMenuWindowLevelKey
#kCGDockWindowLevelKey
#kCGMainMenuWindowLevelKey
#kCGStatusWindowLevelKey
#kCGModalPanelWindowLevelKey
#kCGPopUpMenuWindowLevelKey
#kCGDraggingWindowLevelKey
#kCGScreenSaverWindowLevelKey
#kCGMaximumWindowLevelKey
#kCGOverlayWindowLevelKey
#kCGHelpWindowLevelKey
#kCGUtilityWindowLevelKey
#kCGDesktopIconWindowLevelKey
#kCGCursorWindowLevelKey
#kCGAssistiveTechHighWindowLevelKey
#kCGNumberOfWindowLevelKeys
EndEnumeration
NSNormalWindowLevel = CGWindowLevelForKey(#kCGNormalWindowLevelKey)
NSFloatingWindowLevel = CGWindowLevelForKey(#kCGFloatingWindowLevelKey)
NSSubmenuWindowLevel = CGWindowLevelForKey(#kCGTornOffMenuWindowLevelKey)
NSTornOffMenuWindowLevel = CGWindowLevelForKey(#kCGTornOffMenuWindowLevelKey)
NSMainMenuWindowLevel = CGWindowLevelForKey(#kCGMainMenuWindowLevelKey)
NSStatusWindowLevel = CGWindowLevelForKey(#kCGStatusWindowLevelKey)
NSModalPanelWindowLevel = CGWindowLevelForKey(#kCGModalPanelWindowLevelKey)
NSPopUpMenuWindowLevel = CGWindowLevelForKey(#kCGPopUpMenuWindowLevelKey)
NSScreenSaverWindowLevel = CGWindowLevelForKey(#kCGScreenSaverWindowLevelKey)
NSDockWindowLevel = CGWindowLevelForKey(#kCGDockWindowLevelKey)
Debug NSMainMenuWindowLevel
; that's what you should use, according to your linked article at stackoverflow:
Debug NSMainMenuWindowLevel + 2
Re: Window on top of the StatusBar?
Posted: Tue Jan 12, 2016 8:20 am
by deseven
That's really useful, thanks again!
Re: Window on top of the StatusBar?
Posted: Tue Jan 12, 2016 10:04 am
by Danilo
I think it is best you really use:
Code: Select all
NSMainMenuWindowLevel = CGWindowLevelForKey(#kCGMainMenuWindowLevelKey)
...
CocoaMessage(0,WindowID(0),"setLevel:", NSMainMenuWindowLevel + 2)
Because CGWindowLevelForKey() is an OS function, it could return different results on different OS versions.
So better don't hardcode '24' or '26'.
Re: Window on top of the StatusBar?
Posted: Tue Jan 12, 2016 10:55 am
by deseven
Sure, that's why i asked you where did you get that constant.
No one knows what apple will do in the next os x version...

Re: Window on top of the StatusBar?
Posted: Tue Jan 12, 2016 11:17 am
by wilbert
Depending on what you exactly want to create, you could also use NSScreenSaverWindowLevel .
Re: Window on top of the StatusBar?
Posted: Tue Jan 12, 2016 12:31 pm
by deseven
Nothing special. I just watched
this video and, out of curiosity, decided to learn how it's done.
Re: Window on top of the StatusBar?
Posted: Tue Jan 12, 2016 7:22 pm
by Danilo
deseven wrote:Nothing special. I just watched
this video and, out of curiosity, decided to learn how it's done.
Wouldn't it be better to Resize the Window Width then?
You
move the Window, and it appears on my left screen.
Also had to change:
Code: Select all
If i = DesktopWidth(0) : Break : EndIf
to:
Code: Select all
If i => DesktopWidth(0) : Break : EndIf
otherwise it never ends.
Re: Window on top of the StatusBar?
Posted: Tue Jan 12, 2016 8:04 pm
by deseven
Of course there is a huge room for improvements. For example, it's better to get the system bar height from cocoa, instead of defining it manually.
But i wrote my example in 5 minutes. I didn't think about multi-monitor configurations or other stuff and i don't want to. It's just a proof-of-concept.
I did what i wanted with your help and that's it, nothing more, nothing less.