Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing anywhere on screen in Mac OS X / Objective C

I'm trying to create a little utility that will draw an arbitrary shape on the screen below the mouse pointer (basically like drawing a line that follows the cursor). This could be anywhere on the screen not in a specific window.

My problem is that I can't figure out how to draw on the "screen". Is there a layer or a view object that I can use that references the overall os "view"? I've looked in NSScreen and don't see anything in there.

Any examples or ideas would be great.

Thanks.

like image 714
iamamused Avatar asked Jun 01 '11 02:06

iamamused


1 Answers

Create a transparent overlay window over the area where you want to draw (this could be the whole screen or screens). Set the window level so it appears below the cursor. Apple has some sample code which may help.

like image 80
Nicholas Riley Avatar answered Oct 04 '22 23:10

Nicholas Riley