[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtkmm
Subject:    Re: Fw: [gtkmm] problem about motion_notify_event_impl()
From:       Karl Nelson <kenelson () ece ! ucdavis ! edu>
Date:       2000-02-25 18:59:44
[Download RAW message or body]

This is a multipart MIME message.

I suspect that this is a problem with your program construction and 
not the kit.  You are likely trying to use a resource before it is 
created.

Here is an example code which does what you want.

- --Karl



["test.cc" (text/plain)]

#include <iostream>
#include <gtk--.h>
Gtk::Label *label;

gint motion_handler(GdkEventMotion * event )
  {
    int x,y;
    char buffer[40];
    GdkModifierType state;
    Gdk_Window win(event->window);
    win.get_pointer(x,y,state);
    sprintf(buffer,"(%d,%d)",x,y);
    label->set_text(buffer);
    return TRUE;
  }

int main(int argc, char **argv)
  {
    Gtk::Kit kit(argc,argv);
    Gtk::Window win;
    Gtk::VBox box;
    Gtk::Frame frame;
    Gtk::DrawingArea area;

    frame.add(area);

    label=manage( new Gtk::Label("x,y") );
    box.pack_start(*label);
    box.pack_end(frame);

    win.add(box);

    area.set_usize(200,200);
    area.set_events(GDK_EXPOSURE_MASK| GDK_BUTTON_PRESS_MASK| 
                   GDK_POINTER_MOTION_MASK| GDK_POINTER_MOTION_HINT_MASK);
    area.motion_notify_event.connect(SigC::slot(&motion_handler));

    win.show_all();
    kit.run();
  }

_______________________________________________
to unsubscribe or change your subscription parameters :
http://lists.sourceforge.net/mailman/listinfo/gtkmm-main


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic