objective c - Globally hiding cursor (from background app) -


i want hide cursor statusbar app , i've done research. seems though solution problem found while ago:

globally hide mouse cursor in cocoa/carbon? or http://lists.apple.com/archives/carbon-dev/2006/jan/msg00555.html

but code referred not compile. of guys know either how make code compile (by importing old api or something) or way of achieving (some kind of hack)?

(i know bad idea hide cursor background app, making app functionality pretty essential)

edit:

here's old hack, doesn't work anymore.

long sysvers = getsystemversion();  // trick doesn't work on 10.1  if (sysvers >= 0x1020) {     void cgssetconnectionproperty(int, int, int, int);     int cgscreatecstring(char *);     int cgscreateboolean(bool);     int _cgsdefaultconnection();     void cgsreleaseobj(int);     int propertystring, boolval;      // hack make background cursor setting work     propertystring = cgscreatecstring("setscursorinbackground");     boolval = cgscreateboolean(true);     cgssetconnectionproperty(_cgsdefaultconnection(), _cgsdefaultconnection(), propertystring, boolval);     cgsreleaseobj(propertystring);     cgsreleaseobj(boolval); } 

it gives me 4 errors:

"_cgscreateboolean", referenced from: -[myclass mymethod] in myclass.o

"_getsystemversion", referenced from: -[myclass mymethod] in myclass.o

"_cgscreatecstring", referenced from: -[myclass mymethod] in myclass.o

"_cgsreleaseobj", referenced from: -[myclass mymethod] in myclass.o

you need link against application services framework rid of linker errors.

here's complete example of hack (updated use core foundation):

cat >t.c<<eof #include <applicationservices/applicationservices.h>  int main(void) {     void cgssetconnectionproperty(int, int, cfstringref, cfbooleanref);     int _cgsdefaultconnection();     cfstringref propertystring;      // hack make background cursor setting work     propertystring = cfstringcreatewithcstring(null, "setscursorinbackground", kcfstringencodingutf8);     cgssetconnectionproperty(_cgsdefaultconnection(), _cgsdefaultconnection(), propertystring, kcfbooleantrue);     cfrelease(propertystring);     // hide cursor , wait     cgdisplayhidecursor(kcgdirectmaindisplay);     pause();     return 0; } eof gcc -framework applicationservices t.c ./a.out 

on mac os 10.5 hides cursor until program interrupted. however, performing window server or dock tasks shows cursor.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -