- [mac] Add selector implementations for edit commands (issue #276).
- [mac] Don't generate character events for arrow key presses (issue #294). - Call OnSetFocus when the browser view receives focus/becomes first responder (issue #314). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@281 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
723e5877e9
commit
16e468bb8c
|
@ -81,8 +81,21 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
if (browser)
|
if (browser) {
|
||||||
browser->UIT_SetFocus(browser->UIT_GetWebViewHost(), true);
|
WebViewHost* host = browser->UIT_GetWebViewHost();
|
||||||
|
if (host) {
|
||||||
|
bool handled = false;
|
||||||
|
CefRefPtr<CefClient> client = browser->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
|
||||||
|
if (handler.get())
|
||||||
|
handled = handler->OnSetFocus(browser, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!handled)
|
||||||
|
browser->UIT_SetFocus(host, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
|
|
|
@ -507,6 +507,12 @@ void BrowserWebViewDelegate::scheduleAnimation() {
|
||||||
host->ScheduleAnimation();
|
host->ScheduleAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method is called when:
|
||||||
|
// A. A request is loaded in a window other than the source window
|
||||||
|
// (FrameLoader::loadFrameRequest), or
|
||||||
|
// B. A request is loaded in an already existing popup window
|
||||||
|
// (FrameLoader::createWindow), or
|
||||||
|
// C. A DOM window receives a focus event (DOMWindow::focus)
|
||||||
void BrowserWebViewDelegate::didFocus() {
|
void BrowserWebViewDelegate::didFocus() {
|
||||||
if (WebWidgetHost* host = GetWidgetHost()) {
|
if (WebWidgetHost* host = GetWidgetHost()) {
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
@ -522,6 +528,8 @@ void BrowserWebViewDelegate::didFocus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method is called when a DOM window receives a blur event
|
||||||
|
// (DOMWindow::blur).
|
||||||
void BrowserWebViewDelegate::didBlur() {
|
void BrowserWebViewDelegate::didBlur() {
|
||||||
if (WebWidgetHost* host = GetWidgetHost())
|
if (WebWidgetHost* host = GetWidgetHost())
|
||||||
browser_->UIT_SetFocus(host, false);
|
browser_->UIT_SetFocus(host, false);
|
||||||
|
|
|
@ -156,6 +156,13 @@
|
||||||
|
|
||||||
- (BOOL)becomeFirstResponder {
|
- (BOOL)becomeFirstResponder {
|
||||||
if (browser_ && browser_->UIT_GetWebView()) {
|
if (browser_ && browser_->UIT_GetWebView()) {
|
||||||
|
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
|
||||||
|
if (handler.get() && handler->OnSetFocus(browser_, false))
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
browser_->UIT_GetWebViewHost()->SetFocus(YES);
|
browser_->UIT_GetWebViewHost()->SetFocus(YES);
|
||||||
return [super becomeFirstResponder];
|
return [super becomeFirstResponder];
|
||||||
}
|
}
|
||||||
|
@ -181,6 +188,41 @@
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)undo:(id)sender {
|
||||||
|
if (browser_)
|
||||||
|
browser_->GetFocusedFrame()->Undo();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)redo:(id)sender {
|
||||||
|
if (browser_)
|
||||||
|
browser_->GetFocusedFrame()->Redo();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cut:(id)sender {
|
||||||
|
if (browser_)
|
||||||
|
browser_->GetFocusedFrame()->Cut();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)copy:(id)sender {
|
||||||
|
if (browser_)
|
||||||
|
browser_->GetFocusedFrame()->Copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)paste:(id)sender {
|
||||||
|
if (browser_)
|
||||||
|
browser_->GetFocusedFrame()->Paste();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)delete:(id)sender {
|
||||||
|
if (browser_)
|
||||||
|
browser_->GetFocusedFrame()->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)selectAll:(id)sender {
|
||||||
|
if (browser_)
|
||||||
|
browser_->GetFocusedFrame()->SelectAll();
|
||||||
|
}
|
||||||
|
|
||||||
- (void)registerDragDrop {
|
- (void)registerDragDrop {
|
||||||
dropTarget_.reset([[WebDropTarget alloc] initWithWebView:self]);
|
dropTarget_.reset([[WebDropTarget alloc] initWithWebView:self]);
|
||||||
|
|
||||||
|
|
|
@ -220,8 +220,10 @@ void WebWidgetHost::WheelEvent(NSEvent *event) {
|
||||||
void WebWidgetHost::KeyEvent(NSEvent *event) {
|
void WebWidgetHost::KeyEvent(NSEvent *event) {
|
||||||
WebKeyboardEvent keyboard_event(WebInputEventFactory::keyboardEvent(event));
|
WebKeyboardEvent keyboard_event(WebInputEventFactory::keyboardEvent(event));
|
||||||
webwidget_->handleInputEvent(keyboard_event);
|
webwidget_->handleInputEvent(keyboard_event);
|
||||||
if ([event type] == NSKeyDown) {
|
if ([event type] == NSKeyDown &&
|
||||||
// Send a Char event here to emulate the keyboard events.
|
!([event modifierFlags] & NSNumericPadKeyMask)) {
|
||||||
|
// Send a Char event here to emulate the keyboard events. Do not send a
|
||||||
|
// Char event for arrow keys (NSNumericPadKeyMask modifier will be set).
|
||||||
// TODO(hbono): Bug 20852 <http://crbug.com/20852> implement the
|
// TODO(hbono): Bug 20852 <http://crbug.com/20852> implement the
|
||||||
// NSTextInput protocol and remove this code.
|
// NSTextInput protocol and remove this code.
|
||||||
keyboard_event.type = WebInputEvent::Char;
|
keyboard_event.type = WebInputEvent::Char;
|
||||||
|
|
Loading…
Reference in New Issue