Closed Bug 71014 Opened 24 years ago Closed 23 years ago

arrow keys don't work inside text areas in mfcEmbed

Categories

(Core Graveyard :: Embedding: APIs, defect)

x86
Other
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
mozilla0.9.1

People

(Reporter: jud, Assigned: chak)

References

Details

Attachments

(1 file)

1. goto a text form field.
2. type in it
3. try to use the arrow keys to move the cursor around.
4. notice that you can't move the cursor using the arrow keys.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.1
Here's the latest on this one....

In the latest mfcembed build the arrow keys, the HOME and END keys work OK 
inside a text area.

However, i noticed that these keys stop working once i switch the focus away 
from the main window which contains the textarea and then switch the focus back 
to the window(which has the text area)

The same thing happens from within the latest build of mozilla as well.
*** Bug 71904 has been marked as a duplicate of this bug. ***
I was playing around with this over the weekend and i think it's mainly a focus 
issue we have here:

When creating the embedded browser we pass in a Windows window handle to be used 
as the parent of the embedded browser (via nsIBaseWindow->InitWindow()) and then 
we call create.

This results in three more windows being created (as children on the parent 
window we passed in via InitWindow) the last of which is the actual embedded 
browser.(You can easily see this by using the Windows Spy program). If the page 
has any textareas etc. they are created as children of this last window.

So, when the "frame" window which encloses the embedded browser gets focus it 
should explicitly set the focus to the third window as mentioned above. 
when i explicitly call SetFocus() to the Windows window handle associated with 
the third window the keyboard nav works fine - even when you switch focus away 
from the window and then come back.

Obviously, this is a kludge and we do not want this to be a permanent solution.

I tried looking for an interface which has a SetFocus method available via the 
nsIwebBrowser and the only one which has it is nsIBaseWindow.
However when i call nsIBaseWindow->SetFocus() the arrow keys in a textarea work 
fine, but, if the form has textfield's in it (like in a webmail compose form) 
the arrow keys do not work in the textfields(like the ones for To, Cc etc)

I think we need a SetFocus() method on nsWebBrowser which properly sets the 
focus to the appropriate window without the embedder needing to hack(like 
setting focus to the third window) or by having to know about nsIBaseWindow.

If you're interested, here's the MfcEmbed's code to set focus to the correct 
embedded browser window:

void CBrowserView::OnSetFocus(CWnd *pOldWnd)
{
    CWnd *pLastChild = this;

    // Enumerate thru' all child windows and
    // break out of the loop when we reach the last child
    // or a child with a class name other than "MozillaWindowClass"
    // We'll hit a child with a class name of other than "MozillaWindowClass"
    // when the page has some form elements
    CWnd *pChild = this->GetWindow(GW_CHILD);
    while (pChild != NULL)
    {
        CString className;
        GetClassName(pChild->m_hWnd, className.GetBuffer(_MAX_PATH+1), 
_MAX_PATH);
        className.ReleaseBuffer();
        if(className.CompareNoCase("MozillaWindowClass") != 0)
            break;

        pLastChild = pChild;

        pChild = pChild->GetWindow(GW_CHILD);
    }

    if(pLastChild != NULL)
        pLastChild->SetFocus();
}
The patch above fixes the issue of arrow keys not working when we switch the 
focus away from a window which contains the textarea and then switch the focus 
back to the window(which has the text area)

We still have the following issue:

1. Go to a page with a textfield, such as a search page
2. Enter something in the textfield and and perform a search
3. From the search results page use the back arrow of the browser to navigate 
back
4. The arrow keys will not work in the textfield

Saari mentioned that this happens intermittently in mozilla as well
We're having this problem too with our application. We'll try to find a more
permanent solution. GD
Chris/Jud : Can one of you review the patch (id=28940) for this bug.

I'd like to just checkin the changes to MfcEmbed in that patch. Saari will be 
addressing the nsWebBrowser.cpp changes in bug#70224

The MfcEmbed changes are to just call the Activate() and Deactivate() methods of 
nsIWebBrowserFocus(). Currently they do nothing. Once Chris checks his changes 
in we're in business.

r=saari, you can check in the nsWebBrowser changes too if you like, they look
functionally identical to my patch.
blizzard : Could you please sr= this? Thanks
This patch looks OK to me.  Another thing you might want to do is to change the
event handler that is in nsWebBrowser.cpp that does a lot of this code and
change it to call |nsWebBrowser::Activate| too to save a little code.

Other than that sr=blizzard
HandleEvent() is declared static in nsWebBrowser.h as shown below:

static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);

So, i can't really call Activate()/Deactivate() from HandleEvent()
Sure you can.  There's code in HandleEvent that does this:

  aEvent->widget->GetClientData(data);
  browser = NS_STATIC_CAST(nsWebBrowser *, data);

  [...]

  nsCOMPtr<nsIDOMWindow> domWindow;
  browser->GetContentDOMWindow(getter_AddRefs(domWindow));

Just call browser->Activate().
Just checked it in (without that change). Sorry.

I wish i had waited for your response. Anyway, saari's got more changes coming 
to nsIwebBrowserFocus. I'll work with him to get this change in as well.

Thanks
On second thoughts...

Did'nt see a need to Later the change so went ahead and checked it in.
Fix checked in. Marking FIXED
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 68965 has been marked as a duplicate of this bug. ***
Moving API bug ownership to David Epstein.
QA Contact: mdunn → depstein
Correction: Changing QA contact for the Embed API bugs to David Epstein.
1. Goto 'www.yahoo.com' (as a matter of fact, any other place with a text form 
field)
2. Enter text in the textbox and hit 'Enter'

Result: A form renders with your search results. 
        Go to the input box that has your search text. 
        You cannot move around in that text box, using             
        the left/right/home/end keys.
arrow keys work fine.
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: