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.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/views/textfield_view.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2024-07-02 20:16:55 +02:00
|
|
|
#include "cef/libcef/browser/browser_event_util.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
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;
|
2024-07-02 20:16:55 +02:00
|
|
|
if (!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
|
|
|
}
|