Today I noticed that the idle may be too late: if the user is writing something, then some key strokes may be lost because the idle runs slightly after the widget has been mapped. You may think that's imperceptible to the user, but that's not true in some cases.
So I've tried connecting to the map, map-event and show signals (also "after"), without success: the handler is called slightly before the right time thus grab_focus() will not work.
Then I ended up with this working solution, that will grab the focus as soon as the widget is first drawn to the screen:
void focus_widget (Widget widget) { // it may be already displayed widget.grab_focus (); // grab focus right after the widget is drawn // for the first time ulong sigid = 0; sigid = widget.draw.connect (() => { widget.grab_focus (); widget.disconnect (sigid); return false; }); }
I still don't know exactly what's the best way to grab focus as soon as the widget can really grab it. So if you have any better idea, please let me know :-)
6 comments:
I use show event instead. On GtkEntry draw callback causes the text to be all selected.
I use show event instead. On GtkEntry draw callback causes the text to be all selected.
Nice pick. it's very Useful Article.
SRI ANNAPOORNESHAWARI ASTROLOGY CENTER.Best Astrologer In Massachusetts
Nice pick. it's very Useful Article.
SRIKRISHANA ASTROLOGY.Best Astrologer In Karnataka
Nice pick. it's very Useful Article.
SRI ANNAPOORNESHAWARI ASTROLOGY CENTER.Best Astrologer In Ohio
Thanks for sharing!
ABHIRAM ASTROLOGY CENTER.Best Astrologer In electronic-city
Post a Comment