1 /*! \page script-howto Scripting HowTo
3 * <h2 class="pg">Scripting A Custom Control</h2>
5 * These steps must be taken to provide scripting access for your control.
8 * <li>Register your class Type.
9 * <li>Register Signals and Actions (optional).
10 * <li>Register properties (optional).
14 * <h3 class="pg">Registering your Type, Signals and Actions</h3>
16 * As part of your <b>my-actor.cpp</b> a <em>static</em> "Dali::TypeRegistration" object is created to register MyActor for scripting.
18 * Functions for Creation, Signal Connection and Action are registered with this object.
21 * namespace // type registration
24 * // Register MyActor with base actor CustomActor and creation function CreateCustom
25 * Dali::TypeRegistration mCustomType( typeid(MyActor), typeid(Dali::CustomActor), MyActor::Create );
27 * // Add a signal to the type registration
28 * Dali::TypeSignalConnector signal1( mCustomType, "page-changed", MyActor::DoConnectSignalCustom);
30 * // Add an action to the type registration
31 * Dali::TypeAction action1( mCustomType, "SelectPage", MyActor::DoActionCustom);
36 * The registered handling functions are also static. For example.
39 * BaseHandle MyActor::Create(void)
41 * return MyActor::New();
44 * Dali::Connection MyActor::DoConnectSignalCustom(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
46 * Dali::Connection connection ;
48 * MyActor* actor = dynamic_cast<MyActor*>(object);
50 * if(actor && "page-changed" == signalName)
52 * connection = return actor->PageChangedSignal().Connect( tracker, functor );
58 * bool MyActor::DoActionCustom(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
60 * bool actioned = false ;
62 * MyActor* actor = dynamic_cast<MyActor*>(object) ;
64 * if(actor && "SelectPage" == actionName)
66 * actor->DoSelectPage() ;
74 * <h3 class="pg">Providing Properties for scripting</h3>
76 * Properties can be registered by name to allow script access.
78 * A RegisterProperty() call with property attributes allows the custom class to register non animatable properties.
81 * void MyActor::Initialize()
83 * // Register a non animatable and writeable property.
84 * mPropertyAlphaIndex = Self().RegisterProperty("alpha", 0.0f, Dali::Property::WRITEABLE);
88 * If a non animatable property is set then the class is notified via the OnPropertySet virtual function.
91 * void MyActor::OnPropertySet(Property::Index index, Property::Value propertyValue)
93 * if(index == mPropertyAlphaIndex)
95 * SetAlpha(propertyValue.<float>Get());