macos-carbon

How to force Mac window to foreground?

浪尽此生 提交于 2019-11-29 10:39:34
How can I programmatically force a mac window to be the front window? I have the window handle, and want to ensure that my window is displayed above all other windows. I can use both Carbon & Cocoa for this. For Cocoa, you can set the window level using: [window setLevel:NSFloatingWindowLevel]; A floating window will display above all other regular windows, even if your app isn't active. If you want to make your app active, you can use: [NSApp activateIgnoringOtherApps:YES]; and [window makeKeyAndOrderFront:nil]; If you can (32 bit only) use kOverlayWindowClass: WindowRef carbon_window = NULL;

How to monitor global modifier key state (in any application)?

梦想的初衷 提交于 2019-11-29 08:01:35
问题 I'm using some Carbon code in my Cocoa project for handling global key events (shortcuts) from other applications. Currently I have setup a kEventHotKeyReleased event handler and I can successfully obtain hot keys when my application is not active. That triggers some operation in my application. The problem I have with the behavior of kEventHotKeyReleased is: Say for example I press the Cmd-Shift-P key combination. As soon as I release the "P" key the hot key event is triggered. I need to be

Can't Start Carbon - 12.04 - Python Error - ImportError: cannot import name daemonize

。_饼干妹妹 提交于 2019-11-28 22:30:42
问题 I am really hoping someone can help me as I have spent at-least 15 hours trying to fix this problem. I have been given a task by a potential employer and my solution is to use graphite/carbon/collectd. I am trying to run and install carbon / graphite 0.9.12 but I simply can't get carbon to start. Every time I try and start carbon I end up with the following error. I am using a bash script to install to keep everything consistent. I don't really know python at all so would appreciate any help

Displaying file copy progress using FSCopyObjectAsync

让人想犯罪 __ 提交于 2019-11-28 20:54:53
It appears after much searching that there seems to be a common problem when trying to do a file copy and show a progress indicator relative to the amount of the file that has been copied. After spending some considerable time trying to resolve this issue, I find myself at the mercy of the StackOverflow Gods once again :-) - Hopefully one day I'll be among those that can help out the rookies too! I am trying to get a progress bar to show the status of a copy process and once the copy process has finished, call a Cocoa method. The challenge - I need to make use of File Manager Carbon calls

How can you load a font (TTF) from a file using Core Text?

两盒软妹~` 提交于 2019-11-28 20:36:58
问题 Prior to OSX 10.6, ATSFontActivateFromFileSpecification/ATSFontActivateFromFileReference were available and could be used to load a font from a file. I can't find anything similar in Core Text. 回答1: You can get a CTFontRef from a font file by going via a CGFontRef : CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/path/to/font"), kCFURLPOSIXPathStyle, false); CGDataProviderRef dataProvider = CGDataProviderCreateWithURL(url); CGFontRef theCGFont =

How can Mac OS X games receive low-level keyboard input events?

≯℡__Kan透↙ 提交于 2019-11-28 17:33:23
Games need low-level access to keyboard input. On Windows, there's DirectInput. But what technology do Mac OS X game developers use? Obviously, there's enough Mac games which get keyboard input just right, without the drawbacks of the commonly known solutions: Solution #1: Use keyUp / keyDown events -(void)keyUp:(NSEvent*)event; -(void)keyDown:(NSEvent*)event; Inacceptable drawback: keyDown events are repeated based on the system preference settings for "key repeat rate" and "key repeat delay". This causes an initial keyDown event followed by a pause before it starts repeating at a rate

Controlling OSX windows

核能气质少年 提交于 2019-11-28 17:19:54
I'm trying to control windows of a foreign OSX applications from my application. I'd like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window of the application 4. get the currently active window. (And I'd like to do this either through ObjC/C/C++ apis). What are the API calls that I should be looking for, considering that I have the CGWindowIDs of the windows that I want to control? That is, I'd expect to find functions with signatures of something like: MoveWindow(CGWindowID winId, int x, int y) , ResizeWindow(CGWindowID winId, int

Get real path of application from pid?

人盡茶涼 提交于 2019-11-28 17:17:24
How can I get the process details like name of application & real path of application from process id? I am using Mac OS X. It's quite easy to get the process name / location if you know the PID, just use proc_name or proc_pidpath. Have a look at the following example, which provides the process path: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <libproc.h> int main (int argc, char* argv[]) { pid_t pid; int ret; char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; if ( argc > 1 ) { pid = (pid_t) atoi(argv[1]); ret = proc_pidpath (pid, pathbuf, sizeof(pathbuf)); if

Add Item to Finder Sidebar

流过昼夜 提交于 2019-11-28 11:26:44
I would like to add a new item to the Finder sidebar. I found out that the Finder keeps the list of "places" in `~/Library/Preferences/com.apple.sidebarlists.plist. I was able to read the file using Carbon API and saw that each item had Name, icon and alias. Using a 3rd party application such as PlistEdit Pro I was able to update the alias. My question is how to update the alias using Carbon API. Was not able to find a way to create alias that will open in Finder. It seem that both Dropbox and PlistEditor Pro was able to find the way. Asmus Take a look here : The Shared File List API is new to

What replaces the now-deprecated Carbon.File.FSResolveAliasFile in Python on OSX?

别说谁变了你拦得住时间么 提交于 2019-11-28 10:43:48
问题 In Python 2, I can use the following code to resolve either a MacOS alias or a symbolic link: from Carbon import File File.FSResolveAliasFile(alias_fp, True)[0].as_pathname() where alias_fp is the path to the file I'm curious about, stored as a string (source). However, the documentation cheerfully tells me that the whole Carbon family of modules is deprecated. What should I be using instead? EDIT: I believe the code below is a step in the right direction for the PyObjC approach. It doesn't