Kirix Support Forums

Releasing keyboard focus

Please post all general questions, comments, bug reports, and any other wxWebConnect feedback here.

Releasing keyboard focus

Postby mgsutton on Fri Jul 24, 2009 4:17 pm

Hi Guys,
Thanks for working on such a great control!! I'm having an issue with keyboard focus that I can't seem to correct. I programmatically load an HTML file from disk into a wxWebConnect control in response to a keyboard event (F1 being pressed) in a styled text control. (Scintilla control) However, I can't seem to programmatically return the keyboard focus to the text control after loading the HTML file. I've included the following code in the text control event handler after I load the HTML file:
Code: Select all
if(!GetSTCFocus()) {
    SetSTCFocus(true);
}
if(!HasFocus()) {
    SetFocus();
}


It seems that visually focus is returned to the text editor, but the wxWebConnect still has keyboard focus after the code above.
Any thoughts?
Thanks so much again for a very useful control!!
Matt Sutton
mgsutton
Registered User
 
Posts: 4
Joined: Fri Jul 24, 2009 4:08 pm

Re: Releasing keyboard focus

Postby mgsutton on Fri Jul 24, 2009 4:44 pm

I think I found a workaround by modifying the OpenURI function to take an additional boolean parameter, bGrabFocus that is set to true by default. Then, at the end of the function I replace:
Code: Select all
focus->Activate();

with:
Code: Select all
if(bGrabFocus == true) {
   focus->Activate();
}

My modified OpenURI function definition becomes:
Code: Select all
void OpenURI(const wxString& uri,
             unsigned int flags = wxWEB_LOAD_NORMAL,
             wxWebPostData* post_data = NULL,
             bool bGrabFocus = true);
mgsutton
Registered User
 
Posts: 4
Joined: Fri Jul 24, 2009 4:08 pm

Re: Releasing keyboard focus

Postby jonmmorgan on Fri Apr 22, 2011 10:16 am

I use a modified version of this code to prevent the focus from being grabbed (and, in fact, I always have grab focus false). However, I still found that it would grab focus when I used a wxPython virtual list box and opened a URI when an item was selected in the list (whereas it should have left focus with the list).

I ended up "fixing" this by adding a method to wxWebConnect to force the focus to be deactivated, then after I call OpenURI I explicitly set focus to the list and call the deactivate focus method on the web control. This isn't really a good solution, but I'm not sure I can think of a better one without tracking down exactly where in the interface between wxWidgets and Gecko the incompatibility has come in, which is probably somewhere between difficult and impossible. Any other ideas?
jonmmorgan
Registered User
 
Posts: 94
Joined: Fri May 14, 2010 9:48 am

Return to wxWebConnect Questions, Thoughts & Feedback