Re: How to create a popup?



On Sunday, November 23, 2003, at 04:21 PM, Thomas Bayen wrote:
muppet schrieb:
On Saturday, November 22, 2003, at 10:19 AM, Thomas Bayen wrote:
if I use "$self->{win}->set_property('type','popup')" the input focus does not go into the popup widget but stays in the main >>> window.
you have to explicitly set the focus to be in that new popup window.

This does not work. I can not set the focus into the popup window. Not with the focus_grab method and not with the mouse clicking into it. > :-(

well, it does work, but i'm not sure how to explain why what i did worked. i had a test program built in the style of gtkcombo... of course, i couldn't get the popup to destroy properly and give up the grab, so i didn't post it to the list. can you forgive me? :-)

        $popwin->move ($x, $y);
        $popwin->set_size_request ($width, -1); #$height);
        $popwin->show;
        Gtk2->grab_add ($popwin);
        Gtk2::Gdk->pointer_grab ($popwin->window, 1,
[qw/button-press-mask button-release-mask
                                  pointer-motion-mask/],
                                  undef, undef, 0)
                or die "you suck";;
        Gtk2::Gdk->keyboard_grab ($popwin->window, 0, 0);
        $popwin->grab_focus;
        Gtk2->grab_add ($list);
        if ($list->has_focus) {
                $popwin->window->keyboard_grab (0, 0);
                $list->grab_focus;
        }



But I can't find any documentation about this function/member variable in the C documentation. This can not be true! Please can someone more experienced than me tell me what I did wrong. This one costed me a long time, I want to be better next time. :-)

i find no official mention of widget->allocation in the doc indices, but if you search the
widget page for allocation, you'll find it mentioned in several places.

http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget- size-allocate refers to the allocation argument as the size and position to assign to the widget, which leads me to believe that the x and y in the allocation are relative to the parent.


  my ($x, $y) = $self->window->get_origin;

Please can you tell me why this works? Where in the world is the information hidden that there is a "window" function? I searched about two hours how to become a GdkWindow out of an GtkWindow. Something is really weird in this documentation. :-(

http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget- realize "Creates the GDK (windowing system) resources associated with a widget. For example, widget->window will be created when a widget is realized."

i had to search the whole page for "window" and look through many matches.


Let me guess: "it's an accessor for a member variable, not a *real* function."

yup. a lot of the C structures in Gtk+ have members that historically have been public. in most cases they are things to which you need frequent and fast access, such as the GdkWindow associated with a GtkWidget. most of the work for language bindings over the last couple of years have taught us that this is a poor practice, but this is how the cookie crumbles.


by the way, both are listed in the Gtk2::Widget manpage, together, even:

  window or undef = $widget->window
  allocation = $widget->allocation



--
"that's it! you're a genius!" "yes. that's what i think. do you think i deserve a raise?"
        - dialogue from 'Godzilla versus Mothra', 1964




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