Quantcast
Channel: BlackDog Foundry
Viewing all articles
Browse latest Browse all 27

XcodeExplorer – Checking out the controls

$
0
0

So, assuming you have a great idea to extend some existing behaviour in Xcode4 using a plugin, how do you know what type of objects there are, and how to get a reference to them?

I’ve just added some new functionality to XcodeExplorer that allows you to click around on the various Xcode controls and see where the sit in the view hierarchy, and what type of control they are.

What Does It Look Like?

In the example below, I clicked on the XCEViewClickerWindowController.m file in the navigator, and as you can see, it is an IDENavigatorOutlineView.

View clicker output

Technical Details

In case you are interested, the basic technique is for the plugin to register itself as a listener for mouse click events, and figure out what was clicked on.

The basic gist is the following lines of code:

[NSEvent addLocalMonitorForEventsMatchingMask:NSLeftMouseDownMask handler:^(NSEvent *event) {
	NSView *view = [[[NSApp mainWindow] contentView] hitTest:[event locationInWindow]];
 
	// do something with the view
 
	return event;
}];

Everything else is just plumbing to display the window, and generate the simple view tree output.

Check out the latest XcodeExplorer code now to see it in action.

All articles in this series


Viewing all articles
Browse latest Browse all 27

Trending Articles