Enter key does not insert para in iewin.IEHtmlWindow

Hello
I am using the IEHtmlWindow component to display pages with
contenteditable regions. The problem is that when the user presses
return while editing a contenteditable region, a new paragraph is not
inserted.

If I host the IEHtmlWindow as the child of either the main frame, or a
panel, everything works OK (as long as I use wx.WANTS_CHARS).
But it does not work if the IEHtmlWindow is within a splitterwindow,
(which I need for the app), nor if I nest the IEHtmlWindow within a
panel inside the SplitterWindow.

Further Notes:
* The keystrokes can be intercepted via HTMLDocumentEvents2_onkeydown,
and I have been inserting new paragraphs explicitly, but this has
turned out to be much more complex that using the IE insertParagraph
command, which seems to be buggy when used within contenteditable
regions. Suffice to say that my solution is messy and i'd prefer to do
it right.
* The return key DOES cause a new paragraph to be inserted within a
textarea control
* Control-M will insert a paragraph correctly in any case.
* The tab key works to tab between the html controls and
contenteditable regions, so presumably the TranslateAccelerator call
within wx/lib/activex.py/MSWTranslateMessage, is working for this
case.
* If the return key is pressed, the call to TranslateAccelerator
returns OK, but the next message to come through MSWTranslateMessage
has code 0x491, which does not appear in winuser.h but may be an error
indication??

Im hoping the above gives enough clues to those with more knowledge of
COM, Activex and the wx internals to solve this issue.

Do you use the wx.WANTS_CHAR style on the splitter window too?

···

On 12/25/10 11:14 PM, Paul Wray wrote:

Hello
I am using the IEHtmlWindow component to display pages with
contenteditable regions. The problem is that when the user presses
return while editing a contenteditable region, a new paragraph is not
inserted.

If I host the IEHtmlWindow as the child of either the main frame, or a
panel, everything works OK (as long as I use wx.WANTS_CHARS).
But it does not work if the IEHtmlWindow is within a splitterwindow,
(which I need for the app), nor if I nest the IEHtmlWindow within a
panel inside the SplitterWindow.

--
Robin Dunn
Software Craftsman

Yes.

···

On Dec 27 2010, 3:41 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 12/25/10 11:14 PM, Paul Wray wrote:

> Hello
> I am using the IEHtmlWindow component to display pages with
> contenteditable regions. The problem is that when the user presses
> return while editing a contenteditable region, a new paragraph is not
> inserted.

> If I host the IEHtmlWindow as the child of either the main frame, or a
> panel, everything works OK (as long as I use wx.WANTS_CHARS).
> But it does not work if the IEHtmlWindow is within a splitterwindow,
> (which I need for the app), nor if I nest the IEHtmlWindow within a
> panel inside the SplitterWindow.

Do you use the wx.WANTS_CHAR style on the splitter window too?

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

I have similar problem. I
also have an application that embeds the IE Webbrowser control.

Similar I have discovered
that the enter key does not work inside the TinyMce editor.

In standard html input
controls the enter key works, like textarea, input.

I have been
banging my head against the wall for a few days now.

Today I found
this

http://us.generation-nt.com/answer/pbm-return-key-not-handled-hosted-web-browser-control-help-7081622.html

I is
understand it is exactly the same problem, but they implemented the browser in
a pure MFC application. They too did have problem with return key events on
contenteditable tags, and they solved it.

I have been
trying to convert the code into the wxactivex class. As I understand the PreTranslateMessage()
is a feature that is supported by the MFC message loop and can not be overruled in wxactivex.

I’m really unfamiliar with this low level code. Are you able to get anything from the link?

I think the nearest equivalent in wx is the MSWTranslateMessage method which is overridable in window classes derived from wx.PyAxBaseWindow. In fact it is already overridden in ActiveXCtrl but perhaps it should be doing more. If you want to experiment then that would probably be the place to do it.

···

On 3/15/11 8:32 AM, Thue Udengaard Andersen wrote:

I have similar problem. I also have an application that embeds the IE
Webbrowser control.

Similar I have discovered that the enter key does not work inside the
TinyMce editor.

In standard html input controls the enter key works, like textarea, input.

I have been banging my head against the wall for a few days now.

Today I found this

Discussions et entraide

I is understand it is exactly the same problem, but they implemented the
browser in a pure MFC application. They too did have problem with return
key events on contenteditable tags, and they solved it.

I have been trying to convert the code into the wxactivex class. As I
understand the PreTranslateMessage() is a feature that is supported by
the MFC message loop and can not be overruled in wxactivex.

I'm really unfamiliar with this low level code. Are you able to get
anything from the link?

--
Robin Dunn
Software Craftsman

Hi again,

I have good news. I have solved it in my application.
Your comment made me look inside wxsplitterwindow for the problem.

This is the create function
bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id,
                                   const wxPoint& pos,
                                   const wxSize& size,
                                   long style,
                                   const wxString& name)
{
    // allow TABbing from one window to the other
    style |= wxTAB_TRAVERSAL;

    // we draw our border ourselves to blend the sash with it
    style &= ~wxBORDER_MASK;
    style |= wxBORDER_NONE;

Notice how it always add the wxTAB_TRAVERSAL to the style. After
testing I can confirm that this style is the cause of the problem.

Either you have to edit the wxcode, and remove it.
Or you can set the window style after the constructor has run. Like
this
wxSplitterWindow *splitter = new wxSplitterWindow(this, -1);
long newStyle = splitter->GetWindowStyle();
newStyle &= ~wxTAB_TRAVERSAL;
splitter->SetWindowStyle(newStyle);

The Overrided MSWTranslateMessage is still needed for correct tab
handling inside the browser control. Here is my implementation.

bool wxActiveX::MSWTranslateMessage(WXMSG *msg){

    if (msg->message == WM_KEYDOWN || msg->message == WM_KEYUP) {
        if ( m_oleInPlaceActiveObject.Ok() )
        {
            HRESULT result = m_oleInPlaceActiveObject-

TranslateAccelerator(msg);

            return (result == S_OK);
        }
    }

    return wxWindow::MSWTranslateMessage(msg);
}

···

On Mar 15, 5:36 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 3/15/11 8:32 AM, Thue Udengaard Andersen wrote:

> I have similar problem. I also have an application that embeds the IE
> Webbrowser control.

> Similar I have discovered that the enter key does not work inside the
> TinyMce editor.

> In standard html input controls the enter key works, like textarea, input.

> I have been banging my head against the wall for a few days now.

> Today I found this

>Discussions et entraide

> I is understand it is exactly the same problem, but they implemented the
> browser in a pure MFC application. They too did have problem with return
> key events on contenteditable tags, and they solved it.

> I have been trying to convert the code into the wxactivex class. As I
> understand the PreTranslateMessage() is a feature that is supported by
> the MFC message loop and can not be overruled in wxactivex.

> I'm really unfamiliar with this low level code. Are you able to get
> anything from the link?

I think the nearest equivalent in wx is the MSWTranslateMessage method
which is overridable in window classes derived from wx.PyAxBaseWindow.
In fact it is already overridden in ActiveXCtrl but perhaps it should be
doing more. If you want to experiment then that would probably be the
place to do it.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org