Re: [gtkmm] focus to DialogWindow



Hi Jeff, thx for the hint.

unfortunately I am not able to set the focus to my dialog window
like this:
Something wrong in my code?

	Gtk::MessageDialog dialog(*this, m_message, type, Gtk::BUTTONS_YES_NO);
	dialog.set_title(m_title);
	dialog.set_default_response(Gtk::RESPONSE_NO);
	dialog.set_transient_for(*this);  // Cause window to be on top.
	Glib::signal_idle().connect(SigC::bind_return(SigC::slot(dialog,
&Gtk::Window::present), false));
	m_response = dialog.run();


> The dialog is created and 'show'ed before the constructor finished,
> which resulted in the main application window having focus even though
> the dialog window was on top and modal.  To fix this we caused the
> dialog window to be 'presented' as soon as the application became idle:
> 
>     //
>     // The LOGIN WINDOW
>     //
>     login.show();
>     login.set_transient_for(*this);  // Cause login window to be on top.
> 
>     // Present the window on idle so that the login window will have
> focus and
>     // not the application window.
>     Glib::signal_idle ().
>         connect (SigC::bind_return (SigC::slot (login,
> &Gtk::Window::present),false));
> 
> Jeff



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