ruby-****@sourc*****
ruby-****@sourc*****
2012年 11月 29日 (木) 03:16:58 JST
------------------------- REMOTE_ADDR = 184.145.80.128 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dnd-intro ------------------------- @@ -44,11 +44,13 @@ # Gtk::TreeView#enable_model_drag_source(start_button_mask, targets, actions) treeview.enable_model_drag_source(Gdk::Window::BUTTON1_MASK, TVDND_TARGETS, TVDND_ACTIONS) -or a less involved one: +and a less involved: + (#3) - # Gtk::TreeView#enable_model_drag_source(start_button_mask, targets, actions) + # Gtk::TreeView#enable_model_drag_dest(targets, actions) treeview.enable_model_drag_dest(TVDND_TARGETS, Gdk::DragContext::ACTION_ASK) + The targets argument above identifies all the objects that dnd source and destination will accept. It is convenient to assemble all your targets in a constant since your source and destination widgets need to agree they both will operate with the same drag-and-drop objects (data). Namely, when your source and destination widgets are registered, they should be given the same set of targets as a parameter. The targets argument in either case above is an array of target entries, where each entry is, as mentioned above, the tuple in the form [target, flags, info]. Though you may get away by specifying an empty array ([]) for your targets argument, it is better to create constants with, for your application, meaningful data to be used when registering your source and destination widgets. Here is a code snippet from our next example program in which we build our convenience constants and, indeed, the targets array: