[Lazarus] Mac OS X : Look up in dictionary service...

dmitry boyarintsev skalogryz.lists at gmail.com
Sun Sep 6 21:52:47 CEST 2009


>  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

> 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
TCarbonWidgetSet.RegisterEvents at carbonobjects.inc);

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




More information about the Lazarus mailing list