Re: How to move focus to another window by program?



Thanks Yeti,

I used g_signal_connect_after for the menu activate event for all menu items with actions. It did not make any difference.

I can force focus from a dialog to the top window by gtk_window_present ((GtkWindow *)window ), but gtk_window_present ((GtkWindow *)dlg) does not work the other way around.

Is there a way to force focus from top window to a dialog by the program?
I think there ought to be.

Ken




--- On Wed, 31/3/10, David Nečas <yeti physics muni cz> wrote:

From: David Nečas <yeti physics muni cz>
Subject: Re: How to move focus to another window by program?
To: "Ken Resander" <kresander yahoo com>
Cc: gtk-list gnome org
Date: Wednesday, 31 March, 2010, 11:51 PM

On Wed, Mar 31, 2010 at 08:43:14AM -0700, Ken Resander wrote:
> The program has a top window with a menu. The menu is used for functions directly associated with the top window and for functions associated with dialogs that are brought up via the menu. Each dialog has a single textview and the top window menu contains functions that generate and insert text fragments into the textview.
>
> A dialog gets focus when starting (the title bar has 'active' colour). I then move the caret to the position in the dialog where text is to be inserted and select what to insert from the menu. This causes the focus to move to the top window because the menu is part of it.
>
> The program writes to the correct place in the dialog by:
>
> [code]
>    GtkTextBuffer * buf =  gtk_text_view_get_buffer (textviewwidget) ;
>    gtk_widget_grab_focus ( textviewwidget ); // want to force focus back to dialog
>    ... // prepare text, indentation,buf-insert-position etc
>    gtk_text_buffer_insert (buf,...);
> [/code]
>
> but the focus stays in the top window and I don't understand why. The dialog title bar never changes to active colour, not even a hint or flicker. Having or not having gtk_widget_grab_focus does not seem to make any difference.

It is probably too early to move the focus, the menu will eat it again.
If you connect-after now and it does not help, moving the textview
operation to an idle function should help.

Yeti



New Email names for you!
Get the Email name you've always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!

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