gtkmm 4.17.0
|
Event controller to receive DND drops. More...
#include <gtkmm/droptargetasync.h>
Public Member Functions | |
DropTargetAsync (DropTargetAsync &&src) noexcept | |
DropTargetAsync & | operator= (DropTargetAsync &&src) noexcept |
~DropTargetAsync () noexcept override | |
GtkDropTargetAsync * | gobj () |
Provides access to the underlying C GObject. | |
const GtkDropTargetAsync * | gobj () const |
Provides access to the underlying C GObject. | |
GtkDropTargetAsync * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
void | set_formats (const Glib::RefPtr< const Gdk::ContentFormats > &formats) |
Sets the data formats that this drop target will accept. | |
Glib::RefPtr< Gdk::ContentFormats > | get_formats () |
Gets the data formats that this drop target accepts. | |
Glib::RefPtr< const Gdk::ContentFormats > | get_formats () const |
Gets the data formats that this drop target accepts. | |
void | set_actions (Gdk::DragAction actions) |
Sets the actions that this drop target supports. | |
Gdk::DragAction | get_actions () const |
Gets the actions that this drop target supports. | |
void | reject_drop (const Glib::RefPtr< Gdk::Drop > &drop) |
Sets the drop as not accepted on this drag site. | |
Glib::PropertyProxy< Gdk::DragAction > | property_actions () |
The Gdk::DragActions that this drop target supports. | |
Glib::PropertyProxy_ReadOnly< Gdk::DragAction > | property_actions () const |
The Gdk::DragActions that this drop target supports. | |
Glib::PropertyProxy< Glib::RefPtr< Gdk::ContentFormats > > | property_formats () |
The Gdk::ContentFormats that determines the supported data formats. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::ContentFormats > > | property_formats () const |
The Gdk::ContentFormats that determines the supported data formats. | |
Glib::SignalProxy< bool(const Glib::RefPtr< Gdk::Drop > &)> | signal_accept () |
Only one signal handler is called. | |
Glib::SignalProxy< Gdk::DragAction(const Glib::RefPtr< Gdk::Drop > &, double, double)> | signal_drag_enter () |
Only one signal handler is called. | |
Glib::SignalProxy< Gdk::DragAction(const Glib::RefPtr< Gdk::Drop > &, double, double)> | signal_drag_motion () |
Only one signal handler is called. | |
Glib::SignalProxy< void(const Glib::RefPtr< Gdk::Drop > &)> | signal_drag_leave () |
Glib::SignalProxy< bool(const Glib::RefPtr< Gdk::Drop > &, double, double)> | signal_drop () |
Only one signal handler is called. | |
![]() | |
EventController (EventController &&src) noexcept | |
EventController & | operator= (EventController &&src) noexcept |
~EventController () noexcept override | |
GtkEventController * | gobj () |
Provides access to the underlying C GObject. | |
const GtkEventController * | gobj () const |
Provides access to the underlying C GObject. | |
GtkEventController * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Widget * | get_widget () |
Returns the Gtk::Widget this controller relates to. | |
const Widget * | get_widget () const |
Returns the Gtk::Widget this controller relates to. | |
void | reset () |
Resets the controller to a clean state. | |
PropagationPhase | get_propagation_phase () const |
Gets the propagation phase at which controller handles events. | |
void | set_propagation_phase (PropagationPhase phase) |
Sets the propagation phase at which a controller handles events. | |
PropagationLimit | get_propagation_limit () const |
Gets the propagation limit of the event controller. | |
void | set_propagation_limit (PropagationLimit limit) |
Sets the event propagation limit on the event controller. | |
Glib::ustring | get_name () const |
Gets the name of controller. | |
void | set_name (const Glib::ustring & name) |
Sets a name on the controller that can be used for debugging. | |
Glib::RefPtr< const Gdk::Event > | get_current_event () const |
Returns the event that is currently being handled by the controller. | |
guint32 | get_current_event_time () const |
Returns the timestamp of the event that is currently being handled by the controller. | |
Glib::RefPtr< Gdk::Device > | get_current_event_device () |
Returns the device of the event that is currently being handled by the controller. | |
Glib::RefPtr< const Gdk::Device > | get_current_event_device () const |
Returns the event that is currently being handled by the controller. | |
Gdk::ModifierType | get_current_event_state () const |
Returns the modifier state of the event that is currently being handled by the controller. | |
Glib::PropertyProxy_ReadOnly< Widget * > | property_widget () const |
The widget receiving the Gdk::Events that the controller will handle. | |
Glib::PropertyProxy< PropagationPhase > | property_propagation_phase () |
The propagation phase at which this controller will handle events. | |
Glib::PropertyProxy_ReadOnly< PropagationPhase > | property_propagation_phase () const |
The propagation phase at which this controller will handle events. | |
Glib::PropertyProxy< PropagationLimit > | property_propagation_limit () |
The limit for which events this controller will handle. | |
Glib::PropertyProxy_ReadOnly< PropagationLimit > | property_propagation_limit () const |
The limit for which events this controller will handle. | |
Glib::PropertyProxy< Glib::ustring > | property_name () |
The name for this controller, typically used for debugging purposes. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_name () const |
The name for this controller, typically used for debugging purposes. | |
![]() | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark &key) |
void | set_data (const Quark &key, void *data) |
void | set_data_with_c_callback (const Quark &key, void *data, GDestroyNotify notify) |
void | set_data (const Quark &key, void *data, DestroyNotify notify) |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
![]() | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value) |
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const |
void | set_property (const Glib::ustring &property_name, const PropertyType &value) |
void | get_property (const Glib::ustring &property_name, PropertyType &value) const |
PropertyType | get_property (const Glib::ustring &property_name) const |
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot) |
sigc::connection | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot) |
void | freeze_notify () |
void | thaw_notify () |
virtual void | reference () const |
virtual void | unreference () const |
GObject * | gobj () |
const GObject * | gobj () const |
GObject * | gobj_copy () const |
![]() | |
trackable () noexcept | |
trackable (const trackable &src) noexcept | |
trackable (trackable &&src) noexcept | |
~trackable () | |
void | add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const |
void | notify_callbacks () |
trackable & | operator= (const trackable &src) |
trackable & | operator= (trackable &&src) noexcept |
void | remove_destroy_notify_callback (notifiable *data) const |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< DropTargetAsync > | create (const Glib::RefPtr< const Gdk::ContentFormats > &formats, Gdk::DragAction actions=static_cast< Gdk::DragAction >(0)) |
static Glib::RefPtr< DropTargetAsync > | create (Gdk::DragAction actions=static_cast< Gdk::DragAction >(0)) |
![]() | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::DropTargetAsync > | wrap (GtkDropTargetAsync *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
![]() | |
Glib::RefPtr< Gtk::EventController > | wrap (GtkEventController *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Event controller to receive DND drops.
Gtk::DropTargetAsync is an auxiliary object that can be used to receive Drag-and-Drop operations.
It is the more complete but also more complex method of handling drop operations compared to Gtk::DropTarget and you should only use it if Gtk::DropTarget doesn't provide all the features you need.
To use a Gtk::DropTargetAsync to receive drops on a widget, you create a Gtk::DropTargetAsync object, configure which data formats and actions you support, connect to its signals, and then attach it to the widget with Gtk::Widget::add_controller().
During a drag operation, the first signal that a Gtk::DropTargetAsync emits is signal_accept(), which is meant to determine whether the target is a possible drop site for the ongoing drop. The default handler for the accept signal accepts the drop if it finds a compatible data format and an action that is supported on both sides.
If it is, and the widget becomes a target, you will receive a signal_drag_enter(), followed by signal_drag_motion() as the pointer moves, optionally a signal_drop() when a drop happens, and finally a signal_drag_leave() when the pointer moves off the widget.
The drag-enter and drag-motion handler return a Gdk::DragAction to update the status of the ongoing operation. The drop handler should decide if it ultimately accepts the drop and if it does, it should initiate the data transfer and finish the operation by calling Gdk::Drop::finish().
Between the drag-enter and drag-leave signals the widget is a current drop target, and will receive the Gtk::StateFlags::DROP_ACTIVE state, which can be used by themes to style the widget as a drop target.
|
noexcept |
|
overridenoexcept |
|
static |
|
static |
Gdk::DragAction Gtk::DropTargetAsync::get_actions | ( | ) | const |
Gets the actions that this drop target supports.
Glib::RefPtr< Gdk::ContentFormats > Gtk::DropTargetAsync::get_formats | ( | ) |
Gets the data formats that this drop target accepts.
If the result is nullptr
, all formats are expected to be supported.
Glib::RefPtr< const Gdk::ContentFormats > Gtk::DropTargetAsync::get_formats | ( | ) | const |
Gets the data formats that this drop target accepts.
If the result is nullptr
, all formats are expected to be supported.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GtkDropTargetAsync * Gtk::DropTargetAsync::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
noexcept |
Glib::PropertyProxy< Gdk::DragAction > Gtk::DropTargetAsync::property_actions | ( | ) |
The Gdk::DragActions
that this drop target supports.
Default value: 0
Glib::PropertyProxy_ReadOnly< Gdk::DragAction > Gtk::DropTargetAsync::property_actions | ( | ) | const |
The Gdk::DragActions
that this drop target supports.
Default value: 0
Glib::PropertyProxy< Glib::RefPtr< Gdk::ContentFormats > > Gtk::DropTargetAsync::property_formats | ( | ) |
The Gdk::ContentFormats
that determines the supported data formats.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::ContentFormats > > Gtk::DropTargetAsync::property_formats | ( | ) | const |
The Gdk::ContentFormats
that determines the supported data formats.
void Gtk::DropTargetAsync::reject_drop | ( | const Glib::RefPtr< Gdk::Drop > & | drop | ) |
Sets the drop as not accepted on this drag site.
This function should be used when delaying the decision on whether to accept a drag or not until after reading the data.
drop | The Gdk::Drop of an ongoing drag operation. |
void Gtk::DropTargetAsync::set_actions | ( | Gdk::DragAction | actions | ) |
Sets the actions that this drop target supports.
actions | The supported actions. |
void Gtk::DropTargetAsync::set_formats | ( | const Glib::RefPtr< const Gdk::ContentFormats > & | formats | ) |
Sets the data formats that this drop target will accept.
formats | The supported data formats or nullptr for any format. |
Glib::SignalProxy< bool(const Glib::RefPtr< Gdk::Drop > &)> Gtk::DropTargetAsync::signal_accept | ( | ) |
Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
bool on_my_accept(const Glib::RefPtr<Gdk::Drop>& drop)
Flags: Run Last
Emitted on the drop site when a drop operation is about to begin.
If the drop is not accepted, false
will be returned and the drop target will ignore the drop. If true
is returned, the drop is accepted for now but may be rejected later via a call to Gtk::DropTargetAsync::reject_drop() or ultimately by returning false
from a signal_drop() handler.
The default handler for this signal decides whether to accept the drop based on the formats provided by the drop.
If the decision whether the drop will be accepted or rejected needs further processing, such as inspecting the data, this function should return true
and proceed as is drop was accepted and if it decides to reject the drop later, it should call Gtk::DropTargetAsync::reject_drop().
drop | The Gdk::Drop . |
true
if drop is accepted. Glib::SignalProxy< Gdk::DragAction(const Glib::RefPtr< Gdk::Drop > &, double, double)> Gtk::DropTargetAsync::signal_drag_enter | ( | ) |
Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
Gdk::DragAction on_my_drag_enter(const Glib::RefPtr<Gdk::Drop>& drop, double x, double y)
Flags: Run Last
Emitted on the drop site when the pointer enters the widget.
It can be used to set up custom highlighting.
drop | The Gdk::Drop . |
x | The x coordinate of the current pointer position. |
y | The y coordinate of the current pointer position. |
Glib::SignalProxy< void(const Glib::RefPtr< Gdk::Drop > &)> Gtk::DropTargetAsync::signal_drag_leave | ( | ) |
void on_my_drag_leave(const Glib::RefPtr<Gdk::Drop>& drop)
Flags: Run Last
Emitted on the drop site when the pointer leaves the widget.
Its main purpose it to undo things done in Gtk::DropTargetAsync
drag-enter.
drop | The Gdk::Drop . |
Glib::SignalProxy< Gdk::DragAction(const Glib::RefPtr< Gdk::Drop > &, double, double)> Gtk::DropTargetAsync::signal_drag_motion | ( | ) |
Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
Gdk::DragAction on_my_drag_motion(const Glib::RefPtr<Gdk::Drop>& drop, double x, double y)
Flags: Run Last
Emitted while the pointer is moving over the drop target.
drop | The Gdk::Drop . |
x | The x coordinate of the current pointer position. |
y | The y coordinate of the current pointer position. |
Glib::SignalProxy< bool(const Glib::RefPtr< Gdk::Drop > &, double, double)> Gtk::DropTargetAsync::signal_drop | ( | ) |
Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
bool on_my_drop(const Glib::RefPtr<Gdk::Drop>& drop, double x, double y)
Flags: Run Last
Emitted on the drop site when the user drops the data onto the widget.
The signal handler must determine whether the pointer position is in a drop zone or not. If it is not in a drop zone, it returns false
and no further processing is necessary.
Otherwise, the handler returns true
. In this case, this handler will accept the drop. The handler must ensure that Gdk::Drop::finish() is called to let the source know that the drop is done. The call to Gdk::Drop::finish() must only be done when all data has been received.
To receive the data, use one of the read functions provided by Gdk::Drop such as Gdk::Drop::read_async() or Gdk::Drop::read_value_async().
drop | The Gdk::Drop . |
x | The x coordinate of the current pointer position. |
y | The y coordinate of the current pointer position. |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |