Equivalent for Windows messages (EM_LINEFROMCHAR/EM_LINEINDEX) in OSX/Cocoa - cocoa

ALL,
Is there an equivalent for EM_LINEFROMCHAR/EM_LINEINDEX Windows notification in OSX/Cocoa? I couldn't find anything looking here.
Basically I'm looking to give a position and receive (x,y) coordinate inside the view.

See - (CGPoint)locationForGlyphAtIndex:(NSUInteger)glyphIndex; of NSLayoutManager.
You may wanna read on the relation between NSTextView, NSTextStorage and NSLayoutManager.
https://developer.apple.com/reference/uikit/nslayoutmanager/1403239-locationforglyphatindex?language=objc

Related

How can we get the coordinates of the current text input globally

How is it possible to get the coordinates of the current text input globally?
I am familiar with Quartz Event Taps and NSEvent API for monitoring events, but I have not yet found a way to figure out where on the screen text input is occurring.
Is there an API I am missing?
You can try the Accessibility API.
Take a look at AXUIElementCopyAttributeValue(... kAXFocusedUIElementAttribute ...)
Once you have the focused element, you can grab screen coordinates from it.

NSWindow keep in back of all windows/apps

So not really sure how to even google search this question... But, I'd like to make an NSWindow, reside in the back of all other windows/apps & I want it to be displayed on every Mission Control space (still in the back).
I've seen other applications that do this, so I know it's possible, just don't know how.
(I'm referring to Lion's function called Mission Control where you can switch through different spaces.)
Found the answer, there's a method/enum to make it so that the window will appear in all "spaces" (mission control).
[self.window setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
And a method to keep the window to the farthest back possible.
[self.window setLevel:kCGDesktopIconWindowLevelKey - 1];
All you have to do is use these two methods, and it'll do exactly what I requested. However, I wish there was a way to keep it from animating when coming down from Mission control (there is non to my knowledge).
You want to set the NSWindow's level and collectionBehavior properties.
The window level you'll want to use will depend on what behavior you're after from your window. You can find constants for the available window levels in CoreGraphics/CGWindowLevel.h. I'd suggest trying CGWindowLevelForKey(kCGDesktopIconWindowLevelKey) ± 1.
Which collection behavior you specify will also depend on what behavior you're after. The brief description in your question suggests that NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorCanJoinAllSpaces may be a good starting point.

Binding events to device context objects in wxpython

I am new to wxpython and am running into a problem. What I'd like to do is bind events to device context objects. For example, in one window I would draw a number of different device context objects (i.e. lines, rectangles, etc). First, I would like to be able to select a specific object within the window, for the purposes of linking it to a text box that names it. Second, I'd like to be able to drag the object anywhere within the window, preferably with mouse-down, mouse-move events. I know that this is possible in Tkinter's canvasses, but I can't find any equivalent method in wxpython. Any help would be appreciated.
Thanks,
David
The wxPython demo has an example of selecting objects and dragging them around. There's also the Whyteboard program that has similar functionality and it's written in wxPython too. I would check that out: https://launchpad.net/whyteboard

What is the flag to show the nesting of views in a Mac app?

I have just spet the last few hours trying to find the flag to use in Terminal to launch an app with the colored outlines around the various view elements to show how they are nested. I know that Matt Gemmell covered it during the Cocoa Face Off session of NSConference 2009 (at about the 13minute mark in the video). Unfortunately I can't actually read what he types and he doesn't speak the exact command. I know it has to be in the Apple docs somewhere but the search system is currently not being of any use. It looks like her just adds -showAllViews YES to the end of the command to open TextEdit but that command has no effect in 10.6.6. I have also tried every other capitalization I can think of as well as using view instead of views. Every command opens TextEdit just fine but doesn't show the colored outlines.
Use -NSShowAllDrawing and -NSShowAllDrawingColor:
/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSShowAllDrawing 200 -NSShowAllDrawingColor cycle
-NSShowAllDrawing sets the delay between drawing commands (allowing you enough time to see the drawing update)
-NSShowAllDrawingColor sets the fill colour for the regions with pending drawing operations (see class methods on for NSColor for valid values, or pass it "cycle" to loop through all available colours).

What is the name of this Mac OS X control?

Does this control have a name? Or is it just a bunch of simple controls merged together? If so, what controls are they?
http://img8.imageshack.us/img8/3002/picture2xrb.png
It looks like an NSTableView with an a custom cell type and no column header. Have a look at the documentation for NSTableView's tableView:dataCellForTableColumn:row:. For columns which have the same type for all rows you may also set the cell class in interface builder.
I doubt the search box is part of the same control.
You could open the Application's Nib file to see what is in there. Look inside the application bundle. If the application is called Example then you should be able to find the Nib at Example.app/Contents/Resources/English.lproj/MainMenu.nib.
The best tool for investigating this is fscript, specifically FScriptAnywhere which will let you determine the class and much other information about any visual element of any Cocoa program (and do a lot of other interesting things with Cocoa programs).
In addition to what toholio said, an easy way to get the look and feel of the bottom button bar is with BWToolkit.

Resources