Re: Drag and drop mysteries



Chris Vine wrote:

and for a bit more explanation: http://www.gtk.org/tutorial/ch-dragangdrop.html

Okay, I have finished reading and I'm not really satisfied. My program
still doesn't work.

Please have a look at my source code real quick, it's not much:

In the ctor of my window:

##############################################################

[...]

    // enable drag and drop
    m_target_entries.push_back( Gtk::TargetEntry("FILE") );
    m_target_entries.push_back( Gtk::TargetEntry("DIR") );

    m_view.drag_source_set(
	m_target_entries,
	Gdk::ModifierType( Gdk::BUTTON1_MASK | Gdk::BUTTON2_MASK ),
	Gdk::DragAction( Gdk::ACTION_COPY | Gdk::ACTION_MOVE | Gdk::ACTION_LINK )
	);
    m_view.drag_dest_set(
	m_target_entries,
	Gtk::DEST_DEFAULT_ALL,
	Gdk::DragAction( Gdk::ACTION_COPY | Gdk::ACTION_MOVE | Gdk::ACTION_LINK )
	);

    m_view.signal_drag_data_get()
	.connect( sigc::mem_fun( *this, &DirBrowser::on_drag_data_get ) );
    m_view.signal_drag_data_received()
	.connect( sigc::mem_fun( *this, &DirBrowser::on_drag_data_received ) );

[...]

##############################################################

The signal handlers:

##############################################################

void DirBrowser::on_drag_data_get
( const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData&,
guint, guint )
{
    std::cout << "getting data" << std::endl;
}

void DirBrowser::on_drag_data_received
( const Glib::RefPtr<Gdk::DragContext>& context, int, int, const
Gtk::SelectionData& data, guint, guint time )
{
    std::cout << "data received" << std::endl;
}

##############################################################

The on_drag_data_received is never called. Something is still wrong here.

--
Matthias Kaeppler




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