Hi Richard,

I have tried gtk_window_present. It works forcing focus from a dialog to the 
top window, but not the other way. Everything I have tried has failed. I have 
googled of course, but have not been able to find any success stories, so I am 
beginning to think this cannot be done. I would be happy to be proven wrong of 
course. Anyone?

So, to cut my losses I moved all dialog-dependent functions (that conditionally 
were merged into the top-window menu when needed) to local menus placed in the 
dialogs. Next time I would do that right from the start for GTK.

Ken


--- On Sun, 4/4/10, richard boaz <ivor.b...@gmail.com> wrote:

From: richard boaz <ivor.b...@gmail.com>
Subject: Re: How to move focus to another window by program?
To: "Ken Resander" <kresan...@yahoo.com>
Cc: gtk-list@gnome.org
Date: Sunday, 4 April, 2010, 2:31 AM

did you try using gtk_window_present()?  i would call it first, then grab the 
focus to the proper widget after.
cheers,
richard
p.s. if you've solved it somehow else, i'd be interested to hear how.



On Thu, Apr 1, 2010 at 1:39 PM, Ken Resander <kresan...@yahoo.com> wrote:


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.b...@gmail.com> wrote:



From: richard boaz
 <ivor.b...@gmail.com>
Subject: Re: How to move focus to another window by program?
To: "Ken Resander" <kresan...@yahoo.com>


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 <kresan...@yahoo.com> 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 <y...@physics.muni.cz> wrote:






From: David Nečas <y...@physics.muni.cz>


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



To: "Ken Resander" <kresan...@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!
_______________________________________________

gtk-list mailing list

gtk-list@gnome.org

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@gnome.org

http://mail.gnome.org/mailman/listinfo/gtk-list







      Get your new Email address!
Grab the Email name you&#39;ve always wanted before someone else does!
http://mail.promotions.yahoo.com/newdomains/aa/
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to