1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #include "libcef/browser/views/textfield_view.h" 6 7 #include "libcef/browser/browser_util.h" 8 CefTextfieldView(CefTextfieldDelegate * cef_delegate)9CefTextfieldView::CefTextfieldView(CefTextfieldDelegate* cef_delegate) 10 : ParentClass(cef_delegate) { 11 set_controller(this); 12 } 13 Initialize()14void CefTextfieldView::Initialize() { 15 ParentClass::Initialize(); 16 17 // Use our defaults instead of the Views framework defaults. 18 SetFontList(gfx::FontList(view_util::kDefaultFontList)); 19 } 20 HandleKeyEvent(views::Textfield * sender,const ui::KeyEvent & key_event)21bool CefTextfieldView::HandleKeyEvent(views::Textfield* sender, 22 const ui::KeyEvent& key_event) { 23 DCHECK_EQ(sender, this); 24 25 if (!cef_delegate()) 26 return false; 27 28 CefKeyEvent cef_key_event; 29 if (!browser_util::GetCefKeyEvent(key_event, cef_key_event)) 30 return false; 31 32 return cef_delegate()->OnKeyEvent(GetCefTextfield(), cef_key_event); 33 } 34 OnAfterUserAction(views::Textfield * sender)35void CefTextfieldView::OnAfterUserAction(views::Textfield* sender) { 36 DCHECK_EQ(sender, this); 37 if (cef_delegate()) 38 cef_delegate()->OnAfterUserAction(GetCefTextfield()); 39 } 40