Difference between revisions of "Drop hooks"

From Silhouette Wiki
Jump to navigation Jump to search
(Created page with "Register a "drop hook" with the new <i>trees</i> object. A drop hook is triggered when a specific mime type is dropped into the Trees view. def drop_hook(type, data): pri...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Register a "drop hook" with the new <i>trees</i> object. A drop hook is triggered when a specific mime type is dropped into the Trees view.
+
Register a "drop hook" with the new <i>trees</i> object. A drop hook is triggered when a specific mime type is dropped into the Trees view.
 +
For example, to respond to files from the desktop being dropped, use mime type "text/uri-list".
  
 +
<syntaxhighlight lang="python" enclose>
 
def drop_hook(type, data):
 
def drop_hook(type, data):
 
     print type, data
 
     print type, data
    if type is "text/plain":
 
        node = Node(data)
 
        activeSession().addNode(node)
 
  
 
trees.registerDropHook("text/plain", drop_hook)
 
trees.registerDropHook("text/plain", drop_hook)
trees.registerDropHook("text/uri-list", drop_hook)
+
 
 +
</syntaxhighlight>

Latest revision as of 21:46, 18 November 2016

Register a "drop hook" with the new trees object. A drop hook is triggered when a specific mime type is dropped into the Trees view. For example, to respond to files from the desktop being dropped, use mime type "text/uri-list".

def drop_hook(type, data):
    print type, data

trees.registerDropHook("text/plain", drop_hook)