Re: DnD question




Robert Roebling <roebling@ruf.uni-freiburg.de> writes:

>   Hi,
> 
> I'd like to ask a question on Drag'n'Drop using
> GTK 1.2.X. The normal way to tell GTK what formats
> and what actions (move or copy) a destination window
> accepts is to ue the gtk_drag_dest_set(...) call
> and then you'd hook yourself into a few events,
> mostly "drag_motion", "drag_leave", "drag_drop"
> and "drag_data_received". BTW, where is "drag_enter"?

The first "drag_motion" call.
 
> Is it possible not to declare in advance which
> formats and actions a window (or a part of it)
> supports but to answer to such request in "real-
> time", so that you'd first tell GTK that your
> window can receive any format and if you get
> "drag_motion" events over a specific target area
> you query the available format and action and
> then you tell GTK if you would accept that data
> if it were dropped on that area. 

Yes.

> I guess that
> the gtk_drag_status() call is the way to answer (?)
> which leaves the question how I'd tell GTK that
> my window accepts any data type - or maybe I get
> "drag_motion" events even without ever calling
> gtk_drag_dest_set(...) for that window?

Basically, the way to do this is to not specify
GTK_DRAG_DEST_MOTION and GTK_DRAG_DEST_DROP
in the flags to gtk_drag_dest_set(). Then you
have to respond to the events yourself.

Roughly:

 "drag_motion" - if the coordinates not in a drop
 zone, return FALSE, otherwise, call gtk_drag_status()
 and then return TRUE.

 "drag_drop" - if the drop is not in a drop
 zone, return FALSE, otherwise, if you aren't accepting
 the drag, call gtk_drag_finish() with success == FALSE,
 otherwise, call gtk_drag_data_get()
 
 "drag_data_received" - call gtk_drag_finish() with
 sucess == TRUE.

Also, see 

 http://www.gtk.org/rdp/gtk/gtk-drag-and-drop.html

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]