Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I use a gtk TreeView to display different websites in my Python program. When the selected rows change, the web page is updated to the url field in the store. This works nicely, but a lot of web pages uses javascript to focus an input field. This means I can't use the keyboard to navigate the TreeView.

I don't know how to disable javascript completely, but I also don't want to, because an increasing number of pages are dependent on it. However, I would like to prevent the focus theft. One thing I could do, is to implement some sort of memory about what the user has done, and if focus is removed without user interaction, then I move focus back to the last widget the user interacted with. But this seems ugly. Is there a better way?

share|improve this question
    
Perhaps this should be migrated to StackOverflow, as it's a programming question that doesn't appear Ubuntu-specific. –  Eliah Kagan May 17 '12 at 16:01
1  
The 1.9.1 release of webkit (which isn't even in quantal as of this writing) claims to have fixed" Web content (except plugins) should no longer steal focus from other GTK+ widgets." (mail.gnome.org/archives/gnome-announce-list/2012-April/…) Also see bug: bugs.webkit.org/show_bug.cgi?id=77791 –  andrewsomething Jun 9 '12 at 20:32
    
Could you detect when the page has loaded and then set the focus back to the TreeView? –  jonobacon Jun 17 '12 at 18:53
    
I could prevent focus theft by using webkit.set_property("can-focus", False) until the page has finished loading. If it cannot be focused, then it won't be. But then I'm also prohibiting the user from using the webpage early. That's something that's annoyed me in Ubuntu Software Center. So in order to do it that way, I'd have to track the users intent and set can-focus appropriately. Using a dirty hack in order to circumvent another dirty hack, doesn't sound appetizing at all. I wish I could find a clean solution, but it seems none exist. –  Jo-Erlend Schinstad Jun 18 '12 at 0:26
    
@andrewsomething: that's good news. But flash stuff, for instance, should still be able to steal focus? Anyway; your comment confirms the issue and answers it. So please add it as an answer so that I can accept it. –  Jo-Erlend Schinstad Jun 18 '12 at 0:33

1 Answer 1

up vote 1 down vote accepted

From the comments:

The 1.9.1 release of webkit (which isn't even in quantal as of this writing) claims to have fixed" Web content (except plugins) should no longer steal focus from other GTK+ widgets." (mail.gnome.org/archives/gnome-announce-list/2012-April/…) Also see bug: bugs.webkit.org/show_bug.cgi?id=77791andrewsomething Jun 9 at 20:32

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.