| 1 | = Frequently Asked Questions = |
---|
| 2 | [[PageOutline]] |
---|
| 3 | |
---|
| 4 | == How do I enable dragging? == |
---|
| 5 | |
---|
| 6 | You need to set the ''drag'' property of your element to one of ''drag'' or ''drag-drop''. See [wiki:documentation/RCSS/UserInterface#Dragdrop:thedragproperty Dragging] for full details. |
---|
| 7 | |
---|
| 8 | Note that the element will not be automatically dragged around by the mouse. It will send the ''dragstart'', ''dragend'', ''dragmove'', ''dragover'', ''dragout'' and ''dragdrop'' events, which your application can listen for to move and animate the element as appropriate. |
---|
| 9 | |
---|
| 10 | == How do I bind to events from C++/script? == |
---|
| 11 | |
---|
| 12 | Use the ''AddEventListener'' function, passing in the name of the event you want to bind to (without the "on" prefix), the function to call and whether you want to bind in the capture phase or not. |
---|
| 13 | |
---|
| 14 | From C++: |
---|
| 15 | {{{ |
---|
| 16 | class MyListener : public Rocket::Core::EventListener |
---|
| 17 | { |
---|
| 18 | public: |
---|
| 19 | void ProcessEvent(Rocket::Core::Event& event) |
---|
| 20 | { |
---|
| 21 | printf("Processing event %s", event.GetType().CString()); |
---|
| 22 | } |
---|
| 23 | } |
---|
| 24 | }}} |
---|
| 25 | |
---|
| 26 | {{{ |
---|
| 27 | my_listener = new MyListener(); |
---|
| 28 | element = document->GetElementById("element5"); |
---|
| 29 | element->AddEventListener("click", my_listener, false); |
---|
| 30 | }}} |
---|
| 31 | |
---|
| 32 | From Python: |
---|
| 33 | {{{ |
---|
| 34 | element = document.GetElementById('element5') |
---|
| 35 | element.AddEventListener('click', 'MyFunction(self, document)', False) |
---|
| 36 | }}} |
---|
| 37 | |
---|
| 38 | == Can I change decorators from script? == |
---|
| 39 | |
---|
| 40 | Not directly, however you can change the element's class which can affect which decorators are applied to it. |
---|
| 41 | |
---|
| 42 | == How do I set up custom cursors? == |
---|
| 43 | |
---|
| 44 | You can load documents as cursor objects into your context with the ''LoadMouseCursor'' function. The first cursor to be loaded into a context is the default cursor; if an element does not specify a cursor override, then that is the cursor that will be visible. To override the default cursor, set the ''cursor'' property of your element. See [wiki:documentation/RCSS/UserInterface#Cursors:thecursorproperty Cursors] for full details. |