File: ex_drag_and_drop.rst

package info (click to toggle)
python-enaml 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,284 kB
  • sloc: python: 31,443; cpp: 4,499; makefile: 140; javascript: 68; lisp: 53; sh: 20
file content (63 lines) | stat: -rw-r--r-- 2,232 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
  NOTE: This RST file was generated by `make examples`.
  Do not edit it directly.
  See docs/source/examples/example_doc_generator.py

Drag And Drop Example
===============================================================================

An example of the drag and drop functionality.

In addition to the source widgets in this example, the drop target can
accept data from other processes that have draggable data, such as text
from a web page. The source drag data can also be dropped onto other
processes which support the 'text/plain' mime type used in this example.

The background color of the labels will update to indicate whether the
drop target accepted or rejected the proposed drop action.

If a widget has the ``DragEnabled`` Feature flag enabled, the following
declarative functions are available:

``drag_start``
    The start of the drag operation. Returns a DragData object.

``drag_end``
    The end of the drag operation. Indicates the result of the drop.

If a widget has the ``DropEnabled`` Feature flag enabled, the following
declarative functions are available:

``drag_enter``
    Called when a drag operation enters the widget bounds. The event
    must be accepted in order to receive further drag drop events.

``drag_move``
    Called when a drag operation moves within the widget bounds. This
    is normally not implemented, but it can be useful is certain cases.

``drag_leave``
    Called when a drag operation leaves the widget bounds.

``drop``
    Called when the drag data is dropped on the widget. The event
    can be ignored to indicated to the drag source that the event
    was not accepted. Set the drop action to DropAction.Ignore for
    that case. By default, the event is accepted.

.. TIP:: To see this example in action, download it from
 :download:`drag_and_drop <../../../examples/widgets/drag_and_drop.enaml>`
 and run::

   $ enaml-run drag_and_drop.enaml


Screenshot
-------------------------------------------------------------------------------

.. image:: images/ex_drag_and_drop.png

Example Enaml Code
-------------------------------------------------------------------------------
.. literalinclude:: ../../../examples/widgets/drag_and_drop.enaml
    :language: enaml