Re: [gtkmm] Passing a pointer to a class using D&D
- From: Vladislav Grinchenko <3rdshift comcast net>
- To: "Miller, Ryan D" <MilleRD kscems ksc nasa gov>
- Cc: Gtkmm list <gtkmm-list gnome org>
- Subject: Re: [gtkmm] Passing a pointer to a class using D&D
- Date: Thu, 05 Aug 2004 22:28:44 -0400
Ryan,
why bother - if you dnd in the same application, you can keep
all info you want in a temp object visible to both source and
target. I tried it all a couple of weeks ago and discovered that
passing casted pointers to anything is clearly dangerous.
String are fine but that's about it.
Here's what I ended up with -
source -
http://cvs.sourceforge.net/viewcvs.py/granule/granule/src/DeckList.cpp?rev=1.10&view=auto
(on_drag_begin(), on_drag_data_get())
target -
http://cvs.sourceforge.net/viewcvs.py/granule/granule/src/CardBox.cpp?rev=1.35&view=auto
(on_deck_dropped_cb())
hope this helps,
-Vlad
On Thu, 2004-08-05 at 09:12, Miller, Ryan D wrote:
> Greetings everyone,
>
> Another question for the great readers of gtkmm list. I need to access
> several fields of information from a class after a user performs a drag
> from that class onto another one. (Both classes are derived from
> EventBoxes). I figured out how to pass a single value, such as a
> string, based on the examples by casting the string into a guchar* and
> then using get_data_as_string on the receiving end. In order to pass
> more than one thing, I was hoping to pass the address of the passing and
> then create a pointer to the passing class on the receiving end and use
> that to access what I need. Is this a feasible way to do this? In a
> more concise manner: I would like to pass a pointer to "this" using D&D.
> The code I have right now is below, but I end up with different values
> for the addresses on both ends. Does anyone know how to do this?
>
> In drag_data_get(..) in my passing class:
>
> Selection_data.set( selection_data.get_target(), 8, (const guint8
> *)this, sizeof(this));
>
> In drag_data_received(..) in my receiving class (templateBoxTarget):
>
> templateBoxTarget *t = (templateBoxTarget *)
> selection_data.get_data();
>
> And I have also tried something like this as a shot in the dark, but got
> the same results:
> void *pVoid = (void *)selection_data.get_data();
> templateBoxTarget *t = static_cast<templateBoxTarget *> (pVoid);
>
> Thanks!,
> Ryan
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
--
_____________________________________________________________
Vladislav Grinchenko http://home.comcast.net/~3rdshift/
e-mail: 3rdshift comcast net
Focus on quality, and productivity will follow.
_____________________________________________________________
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]