Adobe 65007312 Programming Guide - Page 14
Creating objects, Class, Description, Object creation, Namespace
UPC - 883919154398
View all Adobe 65007312 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 14 highlights
CHAPTER 1: Using the Lightroom SDK The Lightroom SDK scripting environment 14 Namespace LrView LrXml Description Both a namespace and a class. The namespace functions allow you to obtain the factory object, create bindings between UI elements and data tables, and share placement between UI elements. Both a namespace and a class. The namespace functions allows you to create an XML builder object, and to parse existing XML documents into read-only XML DOM objects. Creating objects When you use the import() function with a class, it returns a constructor function, rather than a table. Use the constructor to create objects, which you can initialize with specific property values. You can then access the functions and properties through the object using colon notation. This example shows the standard way to create and use an object: local LrLogger = import 'LrLogger' -- LrLogger is a constructor function, not a table with more functions local logger = LrLogger( 'myPlugin' ) -- Calling this function returns an instance of LrLogger, which is assigned to -- local variable logger. Notice the lowercase naming convention for objects. logger:enable( 'print' ) logger:warn( 'something bad happened' ) -- Method calls on the object that was just created. There are some exceptions to this technique. You can create some objects using functions in other objects or namespaces, such as LrApplication.activeCatalog(). Others are created and passed to you by Lightroom. The Lightroom SDK defines these classes; for complete details, see the Lightroom SDK API Reference. Class LrCatalog LrCollection Description Provides access to a Lightroom catalog. Provides access to a photo collection. Object creation Returned by LrApplication.activeCatalog() Most classes provide a pointer back to the catalog that contains an object, such as LrPhoto.catalog. Returned by: LrCatalog:createCollection() LrCatalog:createSmartCollection() LrCatalog:getActiveSources() LrCatalog:getCollections() LrCatalog:getCollectionByLocalIdentifier() LrCollectionSet:getChildren() LrCollectionSet:getChildCollections LrPhoto:getContainedCollections()