Re: How to get the word under the mouse pointer?
Re: How to get the word under the mouse pointer?
- Subject: Re: How to get the word under the mouse pointer?
- From: Tommy Nordgren <email@hidden>
- Date: Fri, 7 Dec 2007 05:03:18 +0100
On 7 dec 2007, at 04.32, James Chen wrote:
Hello,
Thanks but what if the front most application is not mine.
Sorry that I didn't describe my question well.
I'd like to write a faceless application that provides a service
similar to
"Look up in Dictionary" which is invoked by global hot key and is
related to
the text/word under mouse pointer. So I don't think I'm able to get
the
NSTextView instance of active app.
Then you need to create a Cocoa Service that operates on currently
selected text.
For info on writing a Cocoa Service, see Anguish - Buck - Yachtman :
Cocoa Programming
(Look out for API changes - the book was completed at about the time
when Jaguar was new.)
Writing a Cocoa Service allows the user to use your tool by just
selecting the word,
and choosing a submenu item of the Services menu.
Best Regards,
James Chen
Presentation Product Division
TEL: +886 2 22263630 ext 8538
FAX: +886 2 22267241
Mailto: email@hidden
http://www.avermedia.com
AVerMedia Technologies, Inc.
簡報產品事業單位: 陳銘崧
圓剛科技(股)公司
This message contains information that may be confidential and
privileged.
Unless you are the addressee (or authorized to receive messages for
the
addressee), you cannot use, copy or disclose to any third party or any
information contained in the message. If you have received the
message in
error, please advise the sender by reply e-mail and delete the
message.
Nothing in this message should be interpreted as a digital or
electronic
signature that can be used to authenticate a contract or to other
legal
document. Thank you very much.
From: Tommy Nordgren <email@hidden>
Date: Fri, 7 Dec 2007 04:14:49 +0100
To: James Chen <email@hidden>
Cc: Cocoa <email@hidden>
Subject: Re: How to get the word under the mouse pointer?
On 7 dec 2007, at 03.16, James Chen wrote:
Hi all,
I'd like to do something like "Look up in Dictionary" (crtl + cmd +
D by
default), which will display a dictionary panel according to the
word under
the mouse.
Does anyone know how to do it?
Any idea will be very appreciated!
Thanks.
Best Regards,
James Chen
Presentation Product Division
TEL: +886 2 22263630 ext 8538
FAX: +886 2 22267241
Mailto: email@hidden
http://www.avermedia.com
AVerMedia Technologies, Inc.
Call the following NSTextView method:
characterIndexForInsertionAtPoint:
Then scan scan backwards and forwards in the text for word
boundaries.
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
email@hidden
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
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