phpgtk2 Drag and Drop

From: Date: Sun, 13 May 2007 09:35:22 +0000
Subject: phpgtk2 Drag and Drop
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7817@lists.php.net to get a copy of this message
Hi, I post a simple PhpGtk2 Drag' n drop example. Just because it's actualy not easy to find that in the official documentation. <?php $window = new Gtkwindow(); $box = new GtkHbox(); $window->add($box); $button1 = new GtkButton('test1'); $box->pack_start($button1); $button2 = new GtkButton('test2'); $box->pack_start($button2); $button1->drag_source_set(Gdk::BUTTON1_MASK, array( array( 'text/plain', 0, 0)), Gdk::ACTION_COPY|Gdk::ACTION_MOVE); $button1->connect('drag-data-get', 'on_drag'); $button2->drag_dest_set(Gtk::DEST_DEFAULT_ALL, array( array( 'text/plain', 0, 0)), Gdk::ACTION_COPY|Gdk::ACTION_MOVE); $button2->connect('drag-data-received', 'on_drop'); function on_drag($widget, $context, $data, $info, $time) { $data->set_text(serialize(array("hello","hello2"))); } function on_drop($widget, $context, $x, $y, $data, $info, $time) { $data2 = unserialize($data->data); echo "received : $data2[0], $data2[1] \n"; } $window->show_all(); gtk::main(); ?> You can find more here : http://www.kksou.com/php-gtk2/articles/drag-and-drop-between-2-GtkTreeViews---Part-1---left-to-right.php :p Thomas

« previous php.gtk.general (#7817) next »