Don't do that:
> >
> > get_window()->set_cursor(cursor);
> >
What about error checking?
Glib::RefPtr<Gdk::Window> window = get_window();
if (window)
window->set_cursor(...);
Dnia 2011-12-11, o godz. 04:50:25
lecas malecas <[email protected]> napisał(a):
> It does work... was running the code in the wrong place, sorry :)
>
>
> On Sun, Dec 11, 2011 at 4:31 AM, lecas malecas <[email protected]>
> wrote:
> > Yep, that works. thanks!
> >
> > Just another doubt, to change the cursor of the mouse (the image).
> >
> >
> > I think its something like this:
> >
> > const Glib::RefPtr< Gdk::Cursor > cursor =
> > Gdk::Cursor::create(Gdk::HAND1);
> >
> > get_window()->set_cursor(cursor);
> >
> > but I'm getting a seg. fault in the last line :(
> >
> >
> > On Sun, Dec 11, 2011 at 3:30 AM, Adam Chyła <[email protected]> wrote:
> >> Hi,
> >> Take a look at that code
> >>
> >> // http://paste.org/42104
> >> // GTKmm 2.4
> >>
> >> #include <gtkmm.h>
> >>
> >> using namespace Gtk;
> >>
> >> class window : public Window
> >> {
> >> public:
> >>
> >> window()
> >> {
> >> set_title("Example");
> >> show_all_children();
> >>
> >> add_events(Gdk::BUTTON_PRESS_MASK);
> >> add_events(Gdk::POINTER_MOTION_MASK);
> >> }
> >>
> >> private:
> >> int mouse_beg_x, mouse_beg_y;
> >> int win_pos_beg_x, win_pos_beg_y;
> >>
> >> bool on_button_press_event(GdkEventButton* event)
> >> {
> >> mouse_beg_x = event->x_root;
> >> mouse_beg_y = event->y_root;
> >>
> >> get_position(win_pos_beg_x, win_pos_beg_y);
> >>
> >> return true;
> >> }
> >>
> >> bool on_motion_notify_event(GdkEventMotion* event)
> >> {
> >> if (event->state & GDK_BUTTON1_MASK)
> >> {
> >> int x = win_pos_beg_x + (event->x_root - mouse_beg_x);
> >> int y = win_pos_beg_y + (event->y_root - mouse_beg_y);
> >>
> >> move(x, y);
> >> }
> >> return true;
> >> }
> >> };
> >>
> >> int main(int argc, char **argv)
> >> {
> >> Gtk::Main kit(argc, argv);
> >>
> >> window win;
> >> Gtk::Main::run(win);
> >>
> >> return 0;
> >> }
> >>
> >>
> >> Good luck
> >> Adam
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list