Here we set up the array of accepted file types:
The widget shall accept files with MIME-Type
text/html, text/plain and
files ending with .dat.
After this we set up the $widget to accept this
files.
<?php
function filesDropped($widget, $arFiles) {
foreach($arFiles as $strFile) {
echo "The file \"$strFile\" has been dropped\r\n";
}
}
$accepted_types = array(
'text/html',
'text/plain',
'.dat'
);
Gtk2_FileDrop::attach($widget, $accepted_types, 'filesDropped', false);
?>
In this example we use a callback function to print out all
dropped files to the console. Further we determine the fourth
parameter as false which means that the widget's
value is not changed automatically.
To use the callback with objects, you pass an array with the reference
of the object: