Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-09

Mac OS X : Look up in dictionary service...

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi Mac OS X gurus,
I've noticed that in applications like Safari and TextEdit, if you highlight a word and right click on it, you always get the "Look up in dictionary" menu option which then launches the Mac OS Dictionary Application. From poking around I found that the Info.plist file of the Dictionary application has a "Services" entry which lists the menu option I mentioned and also what types that it supports via Send Types of NSStringPboardType.

If I want to have something similar for my application, do I have to do anything programmatically in my Lazarus app to be able to handle things properly, or is adding the various entries to Services enough?

Thanks,

Dominique.

Reply by email

dmitry boyarintsev
to Unknown author
If I want to have something similar for my application, do I have to do anything programmatically in my Lazarus app to be able to handle things properly, or is adding the various entries to Services enough?

please read the following article.
http://developer.apple.com/legacy/mac/library/documentation/Carbon/Conceptual/appservices/intro/servintro.html

It would require you do use Carbon API directly. There's no proper LCL wrappers.

thanks,
dmitry

Reply by email

Unknown author
to dmitry boyarintsev

Hi Dimitry,
Thanks for the link, most useful read. Now, are there any simple Lazarus examples that show how to consume Carbon events?
I think from that I can work out how to go about hooking into the Service events. At least I hope so.

Dominique.

dmitry boyarintsev dmitry boyarintsev wrote
please read the following article.

http://developer.apple.com/legacy/mac/library/documentation/Carbon/Conceptual/appservices/intro/servintro.html

It would require you do use Carbon API directly. There's no proper LCL wrappers.

Reply by email

dmitry boyarintsev
to Unknown author
?Thanks for the link, most useful read. Now, are there any simple Lazarus examples that show how to consume Carbon events? I think from that I can work out how to go about hooking into the Service events. At least I hope so.

Carbon Widgetset is the sample on how to consume events.

Take a look at CarbonUtils there're helper InstallXXXEventHandler functions. I can make a better sample, but later.

thanks,
dmitry

Reply by email

Unknown author
to dmitry boyarintsev

Hi Dimitry,
What is the difference between AEInstallEventHandler and your InstallXXXEventHandler functions?
I noticed that in carbonobject.inc in RegisterEvents it calls both, but I don't understand why each is required.

I was also hoping that my application would respond to the kAEOpenDocument event, and looked in the Lazarus code base to see how it handles opening .pas files from the Finder, but couldn't work that out either. I have the application association working with the doc/file am interested in, but can't work out how my app passes that filename to my app to I can actually open it.

Dominique.

dmitry boyarintsev wrote
> ?Thanks for the link, most useful read. Now, are there any simple > Lazarus > examples that show how to consume Carbon events? > I think from that I can work out how to go about hooking into the

Service

Show quoted text 16 lines
> events. At least I hope so. Carbon Widgetset is the sample on how to consume events. Take a look at CarbonUtils there're helper InstallXXXEventHandler functions. I can make a better sample, but later. thanks, dmitry -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

dmitry boyarintsev
to Unknown author
?What is the difference between AEInstallEventHandler and your InstallXXXEventHandler functions? I noticed that in carbonobject.inc in RegisterEvents it calls both, but I don't understand why each is required.

The difference is in getting event targets.

There's common type used: EventTargetRef
But to aquire it, there're different functions:

GetApplicationEventTarget (gets application event target. I guess it's the one you need for using services)

GetControlEventTarget (gets target from ControlRef or HIViewRef) GetWindowEventTarget (target from WindowRef)
etc...

You can learn more about handling carbon events here: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Conceptual/Carbon_Event_Manager/Intro/CarbonEventsIntro.html

API reference can be found at this link:
http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/Carbon_Event_Manager_Ref/Reference/reference.html

Show quoted text 6 lines
I was also hoping that my application would respond to the kAEOpenDocument event, and looked in the Lazarus code base to see how it handles opening .pas files from the Finder, but couldn't work that out either. I have the application association working with the doc/file am interested in, but can't work out how my app passes that filename to my app to I can actually open it.

There're 2 ways:
Lazarus way (prefferable):
Select the main application's form:
set AllowDropFiles to true
implement OnDropFiles event, to load opened files

Depsite of its name the event is called then somebody double-clicks (or tries to open) on the registered file-type in Finder. Dragging files on the form is not yet supported (no need to bug report, as it's known issue).

Carbon only way:
1st) Register kAEOpenDocument event (check procedure );

No matter, what way you chose
you must register the file extension (or document type) to be opened with your application.
It's done by modifying bundle's Info.plist CFBundleDocumentTypes property.

See these docs
http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html#//apple_ref/doc/uid/20001431

Use Lazarus.app Info.plist as an example (or any bundle in the system, i.e. TextEdit)

thanks,
dmitry

Reply by email

Unknown author
to dmitry boyarintsev

Hi Dimitry,
Thanks for the detailed answers, I will pore over the details for handling carbon events tomorrow.

I just wanted to point out that I tried to implement the DropFiles as per Lazarus' but when I double click on my file, the
FormDropFiles event never fires if the application is shutdown, but does fire correctly if the application is already running.

Dominique.

dmitry boyarintsev wrote
> ?What is the difference between AEInstallEventHandler and your > InstallXXXEventHandler functions? > I noticed that in carbonobject.inc in RegisterEvents it calls both, but

I

Show quoted text 15 lines
> don't understand why each is required. The difference is in getting event targets. There's common type used: EventTargetRef But to aquire it, there're different functions: GetApplicationEventTarget (gets application event target. I guess it's the one you need for using services) GetControlEventTarget (gets target from ControlRef or HIViewRef) GetWindowEventTarget (target from WindowRef) etc... You can learn more about handling carbon events here:

http://developer.apple.com/legacy/mac/library/documentation/Carbon/Conceptual/Carbon_Event_Manager/Intro/CarbonEventsIntro.html

API reference can be found at this link:

http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/Carbon_Event_Manager_Ref/Reference/reference.html

Show quoted text 5 lines
> I was also hoping that my application would respond to the > kAEOpenDocument > event, and looked in the Lazarus code base to see how it handles opening > .pas files from the Finder, but couldn't work that out either. I have

the

Show quoted text 24 lines
> application association working with the doc/file am interested in, but > can't work out how my app passes that filename to my app to I can > actually > open it. There're 2 ways: Lazarus way (prefferable): Select the main application's form: set AllowDropFiles to true implement OnDropFiles event, to load opened files Depsite of its name the event is called then somebody double-clicks (or tries to open) on the registered file-type in Finder. Dragging files on the form is not yet supported (no need to bug report, as it's known issue). Carbon only way: 1st) Register kAEOpenDocument event (check procedure ); No matter, what way you chose you must register the file extension (or document type) to be opened with your application. It's done by modifying bundle's Info.plist CFBundleDocumentTypes

property.

See these docs

http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html#//apple_ref/doc/uid/20001431

Show quoted text 12 lines
Use Lazarus.app Info.plist as an example (or any bundle in the system, i.e. TextEdit) thanks, dmitry -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

dmitry boyarintsev
to Unknown author
I just wanted to point out that I tried to implement the DropFiles as per Lazarus' but when I double click on my file, the FormDropFiles event never fires if the application is shutdown, but does fire correctly if the application is already running.

You need to add document bindings at the application bundle and try to place the app to \Applications dir.

thanks,
dmitry

Reply by email