• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How is "Apple + Ctrl + D" implemented?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How is "Apple + Ctrl + D" implemented?


  • Subject: Re: How is "Apple + Ctrl + D" implemented?
  • From: Graham Cox <email@hidden>
  • Date: Mon, 28 Apr 2008 16:51:37 +1000

I imagine it uses some API such as NSLayoutManager's:

- (NSUInteger)glyphIndexForPoint:(NSPoint)point inTextContainer: (NSTextContainer *)container fractionOfDistanceThroughGlyph:(CGFloat *)partialFraction


One you have the glyph index you can find the range of the word it belongs to.


One you have the string of the word it belongs to, you can look it up in dictionary.app using the Application Services API.


hth, though I am guessing to some extent.



G.





On 28 Apr 2008, at 3:55 pm, Ying Bian wrote:
Hi,



I am thinking of developing my own dictionary tool which can detects the
word


under the cursor and automatically (or when a modifier key is pressed) popup
a


translation window.



After researching for a while, I find it more tricky than I estimated.



The accessibility APIs may of help, but for text in a text view, the
returned information

is not enough to reproduce the layout and let me detect the "exact" word
over which the


mouse hovers.



There is a similar functionality in Lepoard (I am not sure if it exists
prior to 10.5):


in any cocoa-based applications, if you press Apple + Ctrl + D, the current
word under


cursor is automatically selected and translated in a popup window. It seems
to me not


implemented with accessibility APIs as it does not require to enable access
for assistive


devices in the Universal Access System Preference panel.



Then, how is this implemented?  I want to get some hints from this.



Thanks,

--
B.Y.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How is "Apple + Ctrl + D" implemented?
      • From: "Ying Bian" <email@hidden>
References: 
 >How is "Apple + Ctrl + D" implemented? (From: "Ying Bian" <email@hidden>)

  • Prev by Date: Re: Another question about Disabling Energy Saving mode
  • Next by Date: Re: Leopard on PPC
  • Previous by thread: How is "Apple + Ctrl + D" implemented?
  • Next by thread: Re: How is "Apple + Ctrl + D" implemented?
  • Index(es):
    • Date
    • Thread