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: Ron Fleckner <email@hidden>
- Date: Fri, 7 Dec 2007 18:31:41 +1100
Hello, James.
I don't actually know how the "Look up in Dictionary" works, but you
couldn't get it using a Cocoa Service. As far as I can tell, Services
operate on the selection and work via a pasteboard; they are disabled
(greyed out) if there is no selection.
My guess is that you could use Carbon calls to define a global hot
key to start your faceless app, then, perhaps also using Carbon, find
out where the mouse pointer is. (Unfortunately, I don't know enough
Carbon to give you an answer to that off the top of my head.) That
would be a start. And that's probably the easy part. As for getting
the word under the mouse pointer of whatever app is frontmost...
you'd have to ask an expert or read lots of documentation.
Having said that, though, a Service would be able to get *selected*
text and that may be adequate in your case.
Ron
On 07/12/2007, at 2:32 PM, 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.
Best Regards,
James Chen
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
_______________________________________________
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:
40ozemail.com.au
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