I have followed a thread in the OSX section how to add controls to the NSThemeFrame
or even to customize the window title. Unfortunately I have little issue that I need to solve too.
As the screen dump shows, I have a small area of 5 pixel where the I cannot drag the window but I like to do that over the full custom frame height.
(subclassed Canvas)
[code]Sub Open()
declare function frame lib CocoaLib selector âframeâ (id As ptr) as NSRect
declare function contentView lib CocoaLib selector âcontentViewâ (id As integer) as ptr
declare function superView lib CocoaLib selector âsuperviewâ (id As Ptr) As Ptr
declare function subviews lib CocoaLib selector âsubviewsâ (id As Ptr) As Ptr
declare function firstObject lib CocoaLib selector âfirstObjectâ (id As Ptr) as ptr
declare sub addSubView lib CocoaLib selector âaddSubview:positioned:relativeTo:â _
(id As Ptr, aView As integer, order As integer, rel As Ptr)
// get the NSThemeFrame
dim cv as ptr = contentView(me.TrueWindow.Handle)
dim themeView As Ptr = superView(cv)
dim firstSubView As Ptr = firstObject(subViews(themeView))
// add our view
addSubView(themeView, me.Handle, 0, firstSubView)
// adjust our view correctly weâve placed in the IDE somewhere
dim barHeight as integer=frame(themeView).h-frame(cv).h
me.Left=0
me.Top=0-barHeight
me.Width=TrueWindow.Width
//
me.LockLeft=true
me.LockRight=true
End Sub[/code]
You shouldnât do this for OS X 10.10 Yosemite or newer. It was never an âapprovedâ method, but with Yosemite, Apple have added some API which will enable you to do this.
I wrote the declares in issue 12.5 of xDev Magazine.
[quote=265523:@Sam Rowlands]You shouldnât do this for OS X 10.10 Yosemite or newer. It was never an âapprovedâ method, but with Yosemite, Apple have added some API which will enable you to do this.
I wrote the declares in issue 12.5 of xDev Magazine.
Yeah, we all got into using the NSThemeFrame in 10.8/10.9 to make interfaces, then Apple change it. I do recall hearing that modifying the NSThemeFrame wasnât entirely stable.
The great thing about the new declares is that you simply layout the window, then with the functions in place, it simply moves it up by the titlebar height. Or if you can, use a toolbar.
The downside is that it doesnât work on 10.9 and lower, so you may want to think about how youâll handle legacy OS versions. With 10.12 or whatever itâs going to be approaching weâve decided to not support 10.9 in our new apps.
just to point that out : setting the mask to NSFullSizeContentViewWindowMask will enabled the window to be layer-backed which
means some drawbacks for labels ect (not crisp anymore).
I can see youâve subclassed the xojo label (NSLabel) for that reason is this true ?