2016-01-19 21:09:01 +01:00
|
|
|
// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found
|
|
|
|
// in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/views/textfield_view.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/browser_util.h"
|
|
|
|
|
|
|
|
CefTextfieldView::CefTextfieldView(CefTextfieldDelegate* cef_delegate)
|
|
|
|
: ParentClass(cef_delegate) {
|
|
|
|
set_controller(this);
|
2016-07-21 23:21:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefTextfieldView::Initialize() {
|
|
|
|
ParentClass::Initialize();
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
// Use our defaults instead of the Views framework defaults.
|
|
|
|
SetFontList(gfx::FontList(view_util::kDefaultFontList));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefTextfieldView::HandleKeyEvent(views::Textfield* sender,
|
|
|
|
const ui::KeyEvent& key_event) {
|
|
|
|
DCHECK_EQ(sender, this);
|
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!cef_delegate()) {
|
2016-01-19 21:09:01 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
CefKeyEvent cef_key_event;
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!browser_util::GetCefKeyEvent(key_event, cef_key_event)) {
|
2016-01-19 21:09:01 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
return cef_delegate()->OnKeyEvent(GetCefTextfield(), cef_key_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefTextfieldView::OnAfterUserAction(views::Textfield* sender) {
|
|
|
|
DCHECK_EQ(sender, this);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (cef_delegate()) {
|
2016-01-19 21:09:01 +01:00
|
|
|
cef_delegate()->OnAfterUserAction(GetCefTextfield());
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|