Xojo Conferences

« MBS Real Studio Plugi… | Home | MBS Real Studio Plugi… »

Tip of the day: Button in window titlebar

Today I was asked how to draw over the whole window in Cocoa. Well it looks like you can simply add a view to NSWindowsMBS.contentview.superview to be able to draw over the whole window, even the title bar. And you can add a button there like on this screenshot:

You simply create a button and use w.contentView.superview.addSubview to add it to the window.
Example project: View in Titlebar.zip
15 01 12 - 11:21
five comments

really cool :)
kvapil (Email) - 15 01 12 - 16:27

It doesn’t work with RB2011R4.1 and 121pr4.
Sebastian - 13 02 12 - 15:38

Well, it does work after all, you just have to change the coordinates of the button in the sample:

v = new MyNSButtonMBS(445, 0, 50, 622)
Sebastian (Email) - 13 02 12 - 15:54

Yes, the coordinates are relative to the bottom left corner of the window, so if the window has a different size, you need to adjust the coordinates.
Christian Schmitz (Email) (URL) - 13 02 12 - 16:20

I left everything in the example project unchanged and ran it. The coordinates above work for the window size in the example zip file.
Sebastian - 13 02 12 - 16:26

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.