Can't support enter key in textarea with OSR mode

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Can't support enter key in textarea with OSR mode

Postby huaouyang » Tue Sep 06, 2016 3:37 am

Hi Guys,

I have a trouble to use textarea in OSR mode, it seems textarea can't support Enter key to break line in OSR mode.

I use the cefclient example with -off-screen-rendering-enabled flag (enable OSR), and I load the example as below to test it, it fails to break line by enter/return key.

Any idea for OSR issue?

Envi:
Mac OS X 10.11
CEF 3.2704

thanks
James

textarea example:
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<textarea  id="desc" rows="6" cols="20" maxlength="200" placeholder="example" spellcheck="false"></textarea>
</body>
</html>
huaouyang
Newbie
 
Posts: 6
Joined: Wed Jul 06, 2016 9:51 pm

Re: Can't support enter key in textarea with OSR mode

Postby huaouyang » Tue Sep 06, 2016 9:12 pm

I use code as below to fix this issue:
Code: Select all
- (void)keyDown:(NSEvent*)event {
    CefRefPtr<CefBrowser> browser = [self getBrowser];
    if (!browser.get())
        return;
   
    if ([event type] != NSFlagsChanged) {
        // The return value of this method seems to always be set to YES,
        // thus we ignore it and ask the host view whether IME is active
        // or not.
        [[self inputContext] handleEvent:event];
       
        CefKeyEvent keyEvent;
        [self getKeyEvent:keyEvent forEvent:event];
       
        keyEvent.type = KEYEVENT_RAWKEYDOWN;
        browser->GetHost()->SendKeyEvent(keyEvent);
    }
}

- (void)keyUp:(NSEvent*)event {
    CefRefPtr<CefBrowser> browser = [self getBrowser];
    if (!browser.get())
        return;
   
    CefKeyEvent keyEvent;
    [self getKeyEvent:keyEvent forEvent:event];
   
    keyEvent.type = KEYEVENT_KEYUP;
    browser->GetHost()->SendKeyEvent(keyEvent);
}


who knows what's the meaning for the cefclient code:
Code: Select all
- (void)keyDown:(NSEvent*)event {
  CefRefPtr<CefBrowser> browser = [self getBrowser];
  if (!browser.get())
    return;

    CefKeyEvent keyEvent;
    [self getKeyEvent:keyEvent forEvent:event];
   
  if ([event type] != NSFlagsChanged) {
    browser->GetHost()->HandleKeyEventBeforeTextInputClient(event);

    // The return value of this method seems to always be set to YES,
    // thus we ignore it and ask the host view whether IME is active
    // or not.
    [[self inputContext] handleEvent:event];

    browser->GetHost()->HandleKeyEventAfterTextInputClient(event);
  }
}
huaouyang
Newbie
 
Posts: 6
Joined: Wed Jul 06, 2016 9:51 pm

Re: Can't support enter key in textarea with OSR mode

Postby magreenblatt » Wed Sep 07, 2016 1:43 pm

The cefclient code is to support IME.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 82 guests