Kouhei Sutou wrote:
yeah, after i sent this mail, i have found the examples, and understood
"[ruby-gnome2-devel-en] Gtk::Drag.source_set produces [BUG] Segmentation fault" on Tue, 23 Jan 2007 15:31:56 +0200,
Dobai-Pataky Bálint <email@example.com> wrote:
i want to have some texts on screen, in a way that user can position
them by dragging them with the mouse.
i decided to use Gtk::Label-s on a Gtk::Layout.
when i try to add drag-and-drop to it, it segfaults.
You don't need to use Gtk::Drag for this. See
sample/misc/drag-move.rb in Ruby/GTK2.
but they are not the right solution for me, what i want to do is to
have a fixed or a layout and some labels on it, and allow the user to
move the labels with the mouse.
so i dropped the dnd, and tried another solution:
i have a layout
i put a label on it
i stay on label's MOTION_NOTIFY event like this:
..case of event type == MOTION_NOTIFY
but this has the following problem:
when the first event occurs the first move is good, but that generates
a new motion event, even the mouse hasn't moved, because the
coordinates of the label are changed.
for example if the label was put at 100,100
mouse button press at x=34.0 y=10.0
event x,y: 34.0,11.0
moving test text to 68.0 21.0
event x,y: 67.0,91.0
moving test text to 101.0 101.0
event x,y: 34.0,12.0
moving test text to 68.0 22.0
event x,y: 67.0,92.0
moving test text to 101.0 102.0
event x,y: 35.0,13.0
moving test text to 69.0 23.0
and the resulting is a label
in every even case is around the mouse,
and in every odd case is somewhere at the edge of the layout.
so unless anyone has a better idea,
i conclude to drop the idea of moving the label in 'realtime'
i rather hide the label and create a rectangle in it's place,
and move the rectangle , using the label's motion event (-if such thing
and on the button release i destroy the rectangle and show the label on
the new position.