Custom container and mouse events



Hello,

I'm try to implement a custom container which allows the user to resize
the widgets it contains (similar to Paned, but allowing more than 2
widgets). Nesting Paned containers to achieve this leads to unintuitive
behavior.

The layout code is complete and works great. Being fairly new to gtk and
gtkmm, I'm having some issues getting the container class to receive
button press/release and motion notify events. Currently I am overriding
on_button_press_event, on_button_release_event, and
on_motion_notify_event to handle user interaction.

I've noticed, when I put notebook widgets inside the container, the
container's motion notify event handler gets called any time the mouse
moves across the notebook tabs (but not the body of the page), with x
and y relative to the top-left point of each tab. When the pointer is in
a space between the container's children, I get no motion notify events
at all. Please could someone give me some insight as to what is
happening there?

Also, I get responses to button press/release events only if I click in
certain places on the notebook tabs, but not in the container's
uninhabited space. The strange thing is, these responses are
intermittent. Sometimes a certain point on a notebook tab triggers the
event, sometimes it does not. This all seems a bit weird to me.

Essentially what I want is for the container to respond to mouse events
so that the user can drag the gap in between each contained widget left
or right to change the size of the widgets either side of it.

Apart from initializing various private members, my constructor
currently only calls the following (I'm sure I should be doing a lot
more, but I'm not sure what):

set_flags(Gtk::NO_WINDOW);
    set_events(get_events() | Gdk::EXPOSURE_MASK |
Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK |
Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK);

Any help much appreciated. Thanks.

Matt.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]