# File gtk/sample/gtk-demo/drawingarea.rb, line 200 def scribble_motion_notify_event(widget, event) unless @pixmap # paranoia check, in case we haven't gotten a configure event return false end # This call is very important; it requests the next motion event. # If you don't call Gdk::Window#pointer you'll only get # a single motion event. The reason is that we specified # Gdk::POINTER_MOTION_HINT_MASK to Gtk::Widget#set_events. # If we hadn't specified that, we could just use event.x, event.y # as the pointer location. But we'd also get deluged in events. # By requesting the next event as we handle the current one, # we avoid getting a huge number of events faster than we # can cope. win, x, y, state = event.window.pointer if (state & Gdk::Window::BUTTON1_MASK) != 0 draw_brush(widget, x, y) end # We've handled it, stop processing return true end