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

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

 



Richard:

Your idea is interesting. Would like to try it, but...

I checked gtk_widget_event ( widget,event ) in the manual which says this function should not be used for synthesizing events. It continues: 'instead, use gtk_main_do_event() so the event will behave as if it were in the event queue'.

However, the manual says this about gtk_main_do_event(): 'While you should not call this function directly, you might want to know how exactly events are handled'.

Not much joy!

Has anyone successfully used any or both of these functions?
 
Or, is there some other way to synthesize events?

Ken


--- On Thu, 1/4/10, richard boaz <ivor.boaz@xxxxxxxxx> wrote:

From: richard boaz <ivor.boaz@xxxxxxxxx>
Subject: Re: How to move focus to another window by program?
To: "Ken Resander" <kresander@xxxxxxxxx>
Date: Thursday, 1 April, 2010, 4:53 PM

you might try this in a different way.

instead of requesting the focus to occur from the top window (to make the dialog have focus), send a message (via an event) to the dialog from the top window, where the dialog will receive the message and then grab focus onto itself.

this way the focus request is happening from inside the dialog itself and not from another window.

richard

On Thu, Apr 1, 2010 at 10:36 AM, Ken Resander <kresander@xxxxxxxxx> wrote:
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@xxxxxxxxxxxxxxx> wrote:

From: David Nečas <yeti@xxxxxxxxxxxxxxx>
Subject: Re: How to move focus to another window by program?
To: "Ken Resander" <kresander@xxxxxxxxx>
Cc: gtk-list@xxxxxxxxx
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!

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list




New Email names for you!
Get the Email name you've always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux