When I use iBooks on Mac, and highlight a word with a mouse, English Thesaurus is shown:

I'd like my program to do similar thing - to appear like this Thesaurus in iBooks.
How can it be reached?
The simplest idea is recognizing that some text is selected, but maybe iBooks has some API (nothing useful at https://developer.apple.com/ibooks/).
Or maybe Mac OS has event "single word selected", and I can subscribe for it.
What kind of app is best suited for that: Cocoa App or some extension/plugin?
I'm not interested in "long way" (context menu):

Any advices will be highly appreciated, because I don't know anything about that.:)
What I think you are looking for is
NSView'sshowDefinitionForAttributedString:atPoint:method or one of its siblings. HTH