Re: DnD: signal handler for signal_data_received not called



Matthias Kaeppler wrote:
Hi,

what if I have a TreeView which is supposed to act both as a source and destination for drag and drop events? This treeview is embedded in a Gtk::ScrolledWindow (class DirBrowser). I have connected three signal handlers, but only two are called. The signal handler which is supposed to be called when the destination receives the drop is never called.

    m_target_entries.push_back( Gtk::TargetEntry("STRING") );
    m_target_entries.push_back( Gtk::TargetEntry("text/plain") );

    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 ) );
    m_view.signal_button_press_event()
.connect_notify( sigc::mem_fun( *this, &DirBrowser::on_button_clicked ) );

[...]

void DirBrowser::on_drag_begin( const Glib::RefPtr<Gdk::DragContext>& context )
{
    //Gtk::ScrolledWindow::on_drag_begin( context );
    std::cout << "dragging" << std::endl;
}

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;
    context->drag_finish(false, false, time);
}



Oh boy, have I wasted hours on this (you maybe remember a similar post by me on this exact same issue a week or two ago).

The solution was to actually set the data to something. Looks like the received handler is really only called if the data sent is not null.

Gosh.

--
Matthias Kaeppler




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