How to create a popup?



Hi,

In my application I want to create a special button widget. It is a kind of a listvalue widget. The widget has a label with the "choosen value". It is a button and the user may press it to change the value. If he does this, I open a popup that uses a complex and very special database-aware RecordSearch-widget to choose a new value.

In the following sourcecode you see the callback function that is used to open the popup. There are three questions about this:


* How can I make that my popup behaves like a real one? For example if I move my main window around with the mouse the popup stays on the old screen position :-(

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. If I make it modal, it gets the focus, but I can't click into the main window any more to close the popup (like a menu popup would). And the "window move" problem stays the same in all these cases.

Is there any simple (perl or C) example about creating my own popups?


* With my code the popup window does not open on the right place. I need the size of the window manager's window decoration to add it to the coordinates. As I understand the documentation this should work with

  (...)=$self->get_root_window->get_frame_extends;
or
  (...)=$self->get_toplevel->get_root_window->get_frame_extends;

but I get the error message

  Can't locate object method "get_root_window" via package ...

Is this method not implemented, if it is how can I call it or how can I find out the root coordinates of my widget in another way?


* I use the "allocation" function to get the coordinates of the widget. I can not find documentation to this function. I found it only with indirect mention. If this is a "documentation bug" I want to report it here...


Thanks,

Thomas


---8X-----------------------------------------------------------------------

sub callback_openpopup{
  my($self)= _;
  $self->{win}->destroy if defined $self->{win};
  $self->{win}=Gtk2::Window->new;
  $self->{win}->set_destroy_with_parent(1);
  $self->{win}->set_decorated(0);
  # What's this for?!?:
  # $self->{win}->set_property('type','popup');
  $self->{win}->set_default_size(400,200);
  # find the right coordinates:
  my($winx,$winy)=$self->get_toplevel->get_position;
  my($x,$y)=($self->allocation->x,$self->allocation->y);
  $self->{win}->move($winx+$x,$winy+$y);
  my $search=Gtk2::RecordSearch->new();
  $self->{win}->add(my $f=Gtk2::Frame->new());
  $f->set_shadow_type('etched-out');
  $f->add($search);
  $self->{win}->show_all;
}




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