Obtaining widget coordinates relative to window


I am trying to locate a widget's coordinates relative to its position in a
displayed window.

I have created a very simple test layout using glade with a single top level
window, a fixed layout, containing a single button. The layout is loaded and
displayed and the program attempts to locate the X,Y of the button widget.

I have tried two methods:

- Using allocation:
  Gtk::Button* button = 0;
  m_refGlade->get_widget("button1", button);
  assert (button);
  cout << button->get_allocation().get_x() << " " <<
button->get_allocation().get_y() << endl;

  Both X,Y values are always -1.

- I have read this post:
  but the return from button->get_window() is always null.

If anyone can help then I'd be extremely grateful.

View this message in context: http://old.nabble.com/Obtaining-widget-coordinates-relative-to-window-tp29489598p29489598.html
Sent from the Gtkmm mailing list archive at Nabble.com.

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