summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/native/native_view_host_gtk.cc2
-rw-r--r--views/controls/native/native_view_host_win.cc7
-rw-r--r--views/controls/native_control.cc11
-rw-r--r--views/controls/native_control_win.cc10
-rw-r--r--views/controls/textfield/native_textfield_win.cc13
-rw-r--r--views/controls/textfield/native_textfield_win.h2
6 files changed, 34 insertions, 11 deletions
diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc
index 4b88067c..7f59144 100644
--- a/views/controls/native/native_view_host_gtk.cc
+++ b/views/controls/native/native_view_host_gtk.cc
@@ -71,8 +71,6 @@ void NativeViewHostGtk::NativeViewAttached() {
host_->Layout();
// TODO(port): figure out focus.
- // FocusManager::InstallFocusSubclass(
- // hwnd, associated_focus_view()_ ? associated_focus_view() : this);
}
void NativeViewHostGtk::NativeViewDetaching() {
diff --git a/views/controls/native/native_view_host_win.cc b/views/controls/native/native_view_host_win.cc
index 04c9edc..d1a5217 100644
--- a/views/controls/native/native_view_host_win.cc
+++ b/views/controls/native/native_view_host_win.cc
@@ -37,16 +37,9 @@ void NativeViewHostWin::NativeViewAttached() {
// Need to set the HWND's parent before changing its size to avoid flashing.
SetParent(host_->native_view(), host_->GetWidget()->GetNativeView());
host_->Layout();
-
- // Register with the focus manager so the associated view is focused when the
- // native control gets the focus.
- View* focus_view = host_->focus_view() ? host_->focus_view() : host_;
- FocusManager::InstallFocusSubclass(host_->native_view(), focus_view);
}
void NativeViewHostWin::NativeViewDetaching() {
- DCHECK(host_->native_view());
- FocusManager::UninstallFocusSubclass(host_->native_view());
installed_clip_ = false;
}
diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc
index cbb375a..2df961e 100644
--- a/views/controls/native_control.cc
+++ b/views/controls/native_control.cc
@@ -81,8 +81,6 @@ class NativeControlContainer : public CWindowImpl<NativeControlContainer,
LRESULT OnCreate(LPCREATESTRUCT create_struct) {
control_ = parent_->CreateNativeControl(m_hWnd);
- FocusManager::InstallFocusSubclass(control_, parent_);
-
// We subclass the control hwnd so we get the WM_KEYDOWN messages.
WNDPROC original_handler =
win_util::SetWindowProc(control_,
@@ -367,6 +365,15 @@ LRESULT CALLBACK NativeControl::NativeControlWndProc(HWND window, UINT message,
if (message == WM_KEYDOWN && native_control->NotifyOnKeyDown()) {
if (native_control->OnKeyDown(static_cast<int>(w_param)))
return 0;
+ } else if (message == WM_SETFOCUS) {
+ // Let the focus manager know that the focus changed.
+ FocusManager* focus_manager =
+ FocusManager::GetFocusManager(native_control->GetNativeControlHWND());
+ if (focus_manager) {
+ focus_manager->SetFocusedView(native_control);
+ } else {
+ NOTREACHED();
+ }
} else if (message == WM_DESTROY) {
win_util::SetWindowProc(window,
reinterpret_cast<WNDPROC>(original_handler));
diff --git a/views/controls/native_control_win.cc b/views/controls/native_control_win.cc
index 2d53f28..b6111fd 100644
--- a/views/controls/native_control_win.cc
+++ b/views/controls/native_control_win.cc
@@ -7,6 +7,7 @@
#include "app/l10n_util_win.h"
#include "base/logging.h"
#include "base/win_util.h"
+#include "views/focus/focus_manager.h"
namespace views {
@@ -193,6 +194,15 @@ LRESULT NativeControlWin::NativeControlWndProc(HWND window,
if (message == WM_KEYDOWN && native_control->NotifyOnKeyDown()) {
if (native_control->OnKeyDown(static_cast<int>(w_param)))
return 0;
+ } else if (message == WM_SETFOCUS) {
+ // Let the focus manager know that the focus changed.
+ FocusManager* focus_manager =
+ FocusManager::GetFocusManager(native_control->native_view());
+ if (focus_manager) {
+ focus_manager->SetFocusedView(native_control->focus_view());
+ } else {
+ NOTREACHED();
+ }
} else if (message == WM_DESTROY) {
win_util::SetWindowProc(window, native_control->original_wndproc_);
}
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index ff20496..d2044a5 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -16,6 +16,7 @@
#include "views/controls/native/native_view_host.h"
#include "views/controls/textfield/native_textfield_win.h"
#include "views/controls/textfield/textfield.h"
+#include "views/focus/focus_manager.h"
#include "views/focus/focus_util_win.h"
#include "views/views_delegate.h"
#include "views/widget/widget.h"
@@ -667,6 +668,18 @@ void NativeTextfieldWin::OnPaste() {
}
}
+void NativeTextfieldWin::OnSetFocus(HWND hwnd) {
+ SetMsgHandled(FALSE); // We still want the default processing of the message.
+
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManager(m_hWnd);
+ if (!focus_manager) {
+ NOTREACHED();
+ return;
+ }
+ focus_manager->SetFocusedView(textfield_);
+}
+
void NativeTextfieldWin::OnSysChar(TCHAR ch, UINT repeat_count, UINT flags) {
// Nearly all alt-<xxx> combos result in beeping rather than doing something
// useful, so we discard most. Exceptions:
diff --git a/views/controls/textfield/native_textfield_win.h b/views/controls/textfield/native_textfield_win.h
index 194614a..58034c0 100644
--- a/views/controls/textfield/native_textfield_win.h
+++ b/views/controls/textfield/native_textfield_win.h
@@ -74,6 +74,7 @@ class NativeTextfieldWin
MSG_WM_NCPAINT(OnNCPaint)
MSG_WM_RBUTTONDOWN(OnNonLButtonDown)
MSG_WM_PASTE(OnPaste)
+ MSG_WM_SETFOCUS(OnSetFocus)
MSG_WM_SYSCHAR(OnSysChar) // WM_SYSxxx == WM_xxx with ALT down
MSG_WM_SYSKEYDOWN(OnKeyDown)
END_MSG_MAP()
@@ -122,6 +123,7 @@ class NativeTextfieldWin
void OnNCPaint(HRGN region);
void OnNonLButtonDown(UINT keys, const CPoint& point);
void OnPaste();
+ void OnSetFocus(HWND hwnd);
void OnSysChar(TCHAR ch, UINT repeat_count, UINT flags);
// Helper function for OnChar() and OnKeyDown() that handles keystrokes that