Michael Maclean
Thursday, April 07, 2005
For some random reason I started playing with Xcode and Cocoa last night on my Mac. I decided that I wanted to write a Web browser that could go full screen, with no chrome or menubars or anything, on a given display: this was something we needed to be able to do at the Union at the end of term, and had to hack by using browser windows that were far too big for the display that they were being shown on. I guessed that by using an embedded Safari Web view it wouldn't be too difficult. I was right. It is very easy to create a basic browser without actually writing any code at all: you drag the WebView object, a text field and a few buttons for back, forward, stop, and refresh onto the page and draw some lines between them and it all just works. This page on macdevcenter.com describes how.

After a lot of googling I was able to find some example code using some low-level functions to set up a "shielding" window to prevent dialogue boxes being displayed over the page, and that also worked, but I suspected it was overkill for what I wanted to do. By removing all the CoreFoundation code I found I was able to use about 5 lines of pure Objective-C to get a list of displays, and choose one, then create a window covering the entire screen. It all works, but now I just need to work out how to make it go back to using a window. I think I know how, but I have other things I need to be doing right now. When the code is a bit less embarrasing I'll probably release it to the world. I was very impressed at how easy it is to do these things with Cocoa, once you get over the slightly strange Objective-C syntax. There are far too many square brackets for my liking.
I talked to the computer, it hates me

03/01/2004 - 04/01/2004 / 04/01/2004 - 05/01/2004 / 05/01/2004 - 06/01/2004 / 07/01/2004 - 08/01/2004 / 01/01/2005 - 02/01/2005 / 02/01/2005 - 03/01/2005 / 04/01/2005 - 05/01/2005 / 06/01/2005 - 07/01/2005 / 08/01/2005 - 09/01/2005 / 09/01/2005 - 10/01/2005 / 10/01/2005 - 11/01/2005 /

Michael Maclean's photos More of Michael Maclean's photos

Powered by Blogger