diff --git a/include/capi/views/cef_view_capi.h b/include/capi/views/cef_view_capi.h index eeeb642b7..e60b97533 100644 --- a/include/capi/views/cef_view_capi.h +++ b/include/capi/views/cef_view_capi.h @@ -148,6 +148,18 @@ typedef struct _cef_view_t { /// void (CEF_CALLBACK *set_id)(struct _cef_view_t* self, int id); + /// + // Returns the group id of this View, or -1 if not set. + /// + int (CEF_CALLBACK *get_group_id)(struct _cef_view_t* self); + + /// + // A group id is used to tag Views which are part of the same logical group. + // Focus can be moved between views with the same group using the arrow keys. + // The group id is immutable once it's set. + /// + void (CEF_CALLBACK *set_group_id)(struct _cef_view_t* self, int group_id); + /// // Returns the View that contains this View, if any. /// diff --git a/include/capi/views/cef_view_delegate_capi.h b/include/capi/views/cef_view_delegate_capi.h index 07ea4c547..67725d545 100644 --- a/include/capi/views/cef_view_delegate_capi.h +++ b/include/capi/views/cef_view_delegate_capi.h @@ -105,6 +105,18 @@ typedef struct _cef_view_delegate_t { /// void (CEF_CALLBACK *on_child_view_changed)(struct _cef_view_delegate_t* self, struct _cef_view_t* view, int added, struct _cef_view_t* child); + + /// + // Called when |view| gains focus. + /// + void (CEF_CALLBACK *on_focus)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view); + + /// + // Called when |view| loses focus. + /// + void (CEF_CALLBACK *on_blur)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view); } cef_view_delegate_t; diff --git a/include/views/cef_view.h b/include/views/cef_view.h index d694ec516..78422fecd 100644 --- a/include/views/cef_view.h +++ b/include/views/cef_view.h @@ -145,6 +145,20 @@ class CefView : public CefBaseRefCounted { /*--cef()--*/ virtual void SetID(int id) =0; + /// + // Returns the group id of this View, or -1 if not set. + /// + /*--cef()--*/ + virtual int GetGroupID() =0; + + /// + // A group id is used to tag Views which are part of the same logical group. + // Focus can be moved between views with the same group using the arrow keys. + // The group id is immutable once it's set. + /// + /*--cef()--*/ + virtual void SetGroupID(int group_id) =0; + /// // Returns the View that contains this View, if any. /// diff --git a/include/views/cef_view_delegate.h b/include/views/cef_view_delegate.h index 1bfc7bb1f..523b05282 100644 --- a/include/views/cef_view_delegate.h +++ b/include/views/cef_view_delegate.h @@ -108,6 +108,18 @@ class CefViewDelegate : public virtual CefBaseRefCounted { virtual void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) {} + + /// + // Called when |view| gains focus. + /// + /*--cef()--*/ + virtual void OnFocus(CefRefPtr view) {} + + /// + // Called when |view| loses focus. + /// + /*--cef()--*/ + virtual void OnBlur(CefRefPtr view) {} }; #endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_ diff --git a/libcef/browser/views/view_impl.h b/libcef/browser/views/view_impl.h index c0fcd0a94..32270c166 100644 --- a/libcef/browser/views/view_impl.h +++ b/libcef/browser/views/view_impl.h @@ -377,6 +377,8 @@ CEF_VIEW_IMPL_T class CefViewImpl : public CefViewAdapter, CefRefPtr GetWindow() override; int GetID() override; void SetID(int id) override; + int GetGroupID() override; + void SetGroupID(int group_id) override; CefRefPtr GetParentView() override; CefRefPtr GetViewForID(int id) override; void SetBounds(const CefRect& bounds) override; @@ -507,6 +509,19 @@ CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetID(int id) { root_view()->set_id(id); } + +CEF_VIEW_IMPL_T int CEF_VIEW_IMPL_D::GetGroupID() { + CEF_REQUIRE_VALID_RETURN(0); + return root_view()->GetGroup(); +} + +CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetGroupID(int group_id) { + CEF_REQUIRE_VALID_RETURN_VOID(); + if (root_view()->GetGroup() != -1) + return; + root_view()->SetGroup(group_id); +} + CEF_VIEW_IMPL_T CefRefPtr CEF_VIEW_IMPL_D::GetParentView() { CEF_REQUIRE_VALID_RETURN(nullptr); views::View* view = root_view()->parent(); diff --git a/libcef/browser/views/view_view.h b/libcef/browser/views/view_view.h index c72ac3fc2..c095e1dc9 100644 --- a/libcef/browser/views/view_view.h +++ b/libcef/browser/views/view_view.h @@ -72,6 +72,8 @@ CEF_VIEW_VIEW_T class CefViewView : public ViewsViewClass { void Layout() override; void ViewHierarchyChanged( const views::View::ViewHierarchyChangedDetails& details) override; + void OnFocus() override; + void OnBlur() override; // Return true if this View is expected to have a minimum size (for example, // a button where the minimum size is based on the label). @@ -162,6 +164,18 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::ViewHierarchyChanged( ParentClass::ViewHierarchyChanged(details); } +CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnFocus() { + if (cef_delegate()) + cef_delegate()->OnFocus(GetCefView()); + ParentClass::OnFocus(); +} + +CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnBlur() { + if (cef_delegate()) + cef_delegate()->OnBlur(GetCefView()); + ParentClass::OnBlur(); +} + CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyChildViewChanged( const views::View::ViewHierarchyChangedDetails& details) { if (!cef_delegate()) diff --git a/libcef_dll/cpptoc/views/browser_view_cpptoc.cc b/libcef_dll/cpptoc/views/browser_view_cpptoc.cc index 23667e731..9d84f8adc 100644 --- a/libcef_dll/cpptoc/views/browser_view_cpptoc.cc +++ b/libcef_dll/cpptoc/views/browser_view_cpptoc.cc @@ -326,6 +326,35 @@ void CEF_CALLBACK browser_view_set_id(struct _cef_view_t* self, int id) { id); } +int CEF_CALLBACK browser_view_get_group_id(struct _cef_view_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefBrowserViewCppToC::Get(reinterpret_cast( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK browser_view_set_group_id(struct _cef_view_t* self, + int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserViewCppToC::Get(reinterpret_cast( + self))->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK browser_view_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -933,6 +962,8 @@ CefBrowserViewCppToC::CefBrowserViewCppToC() { GetStruct()->base.get_window = browser_view_get_window; GetStruct()->base.get_id = browser_view_get_id; GetStruct()->base.set_id = browser_view_set_id; + GetStruct()->base.get_group_id = browser_view_get_group_id; + GetStruct()->base.set_group_id = browser_view_set_group_id; GetStruct()->base.get_parent_view = browser_view_get_parent_view; GetStruct()->base.get_view_for_id = browser_view_get_view_for_id; GetStruct()->base.set_bounds = browser_view_set_bounds; diff --git a/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc index f7a14b401..d58fc04ad 100644 --- a/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc @@ -270,6 +270,42 @@ void CEF_CALLBACK browser_view_delegate_on_child_view_changed( CefViewCToCpp::Wrap(child)); } +void CEF_CALLBACK browser_view_delegate_on_focus( + struct _cef_view_delegate_t* self, cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefBrowserViewDelegateCppToC::Get( + reinterpret_cast(self))->OnFocus( + CefViewCToCpp::Wrap(view)); +} + +void CEF_CALLBACK browser_view_delegate_on_blur( + struct _cef_view_delegate_t* self, cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefBrowserViewDelegateCppToC::Get( + reinterpret_cast(self))->OnBlur( + CefViewCToCpp::Wrap(view)); +} + } // namespace @@ -293,6 +329,8 @@ CefBrowserViewDelegateCppToC::CefBrowserViewDelegateCppToC() { browser_view_delegate_on_parent_view_changed; GetStruct()->base.on_child_view_changed = browser_view_delegate_on_child_view_changed; + GetStruct()->base.on_focus = browser_view_delegate_on_focus; + GetStruct()->base.on_blur = browser_view_delegate_on_blur; } template<> CefRefPtr CefCppToCRefCounted( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK button_set_group_id(struct _cef_view_t* self, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefButtonCppToC::Get(reinterpret_cast(self))->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK button_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -916,6 +943,8 @@ CefButtonCppToC::CefButtonCppToC() { GetStruct()->base.get_window = button_get_window; GetStruct()->base.get_id = button_get_id; GetStruct()->base.set_id = button_set_id; + GetStruct()->base.get_group_id = button_get_group_id; + GetStruct()->base.set_group_id = button_set_group_id; GetStruct()->base.get_parent_view = button_get_parent_view; GetStruct()->base.get_view_for_id = button_get_view_for_id; GetStruct()->base.set_bounds = button_set_bounds; diff --git a/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc index 5ddb2f25e..7fc694f34 100644 --- a/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc @@ -172,6 +172,42 @@ void CEF_CALLBACK button_delegate_on_child_view_changed( CefViewCToCpp::Wrap(child)); } +void CEF_CALLBACK button_delegate_on_focus(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefButtonDelegateCppToC::Get(reinterpret_cast( + self))->OnFocus( + CefViewCToCpp::Wrap(view)); +} + +void CEF_CALLBACK button_delegate_on_blur(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefButtonDelegateCppToC::Get(reinterpret_cast( + self))->OnBlur( + CefViewCToCpp::Wrap(view)); +} + } // namespace @@ -187,6 +223,8 @@ CefButtonDelegateCppToC::CefButtonDelegateCppToC() { button_delegate_on_parent_view_changed; GetStruct()->base.on_child_view_changed = button_delegate_on_child_view_changed; + GetStruct()->base.on_focus = button_delegate_on_focus; + GetStruct()->base.on_blur = button_delegate_on_blur; } template<> CefRefPtr CefCppToCRefCounted( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK label_button_set_group_id(struct _cef_view_t* self, + int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefLabelButtonCppToC::Get(reinterpret_cast( + self))->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK label_button_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1152,6 +1181,8 @@ CefLabelButtonCppToC::CefLabelButtonCppToC() { GetStruct()->base.base.get_window = label_button_get_window; GetStruct()->base.base.get_id = label_button_get_id; GetStruct()->base.base.set_id = label_button_set_id; + GetStruct()->base.base.get_group_id = label_button_get_group_id; + GetStruct()->base.base.set_group_id = label_button_set_group_id; GetStruct()->base.base.get_parent_view = label_button_get_parent_view; GetStruct()->base.base.get_view_for_id = label_button_get_view_for_id; GetStruct()->base.base.set_bounds = label_button_set_bounds; diff --git a/libcef_dll/cpptoc/views/menu_button_cpptoc.cc b/libcef_dll/cpptoc/views/menu_button_cpptoc.cc index 1a9247f42..bbe47edf4 100644 --- a/libcef_dll/cpptoc/views/menu_button_cpptoc.cc +++ b/libcef_dll/cpptoc/views/menu_button_cpptoc.cc @@ -569,6 +569,35 @@ void CEF_CALLBACK menu_button_set_id(struct _cef_view_t* self, int id) { id); } +int CEF_CALLBACK menu_button_get_group_id(struct _cef_view_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefMenuButtonCppToC::Get(reinterpret_cast( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK menu_button_set_group_id(struct _cef_view_t* self, + int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefMenuButtonCppToC::Get(reinterpret_cast( + self))->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK menu_button_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1189,6 +1218,8 @@ CefMenuButtonCppToC::CefMenuButtonCppToC() { GetStruct()->base.base.base.get_window = menu_button_get_window; GetStruct()->base.base.base.get_id = menu_button_get_id; GetStruct()->base.base.base.set_id = menu_button_set_id; + GetStruct()->base.base.base.get_group_id = menu_button_get_group_id; + GetStruct()->base.base.base.set_group_id = menu_button_set_group_id; GetStruct()->base.base.base.get_parent_view = menu_button_get_parent_view; GetStruct()->base.base.base.get_view_for_id = menu_button_get_view_for_id; GetStruct()->base.base.base.set_bounds = menu_button_set_bounds; diff --git a/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc index b71d8cc03..5305cac41 100644 --- a/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc @@ -199,6 +199,42 @@ void CEF_CALLBACK menu_button_delegate_on_child_view_changed( CefViewCToCpp::Wrap(child)); } +void CEF_CALLBACK menu_button_delegate_on_focus( + struct _cef_view_delegate_t* self, cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefMenuButtonDelegateCppToC::Get( + reinterpret_cast(self))->OnFocus( + CefViewCToCpp::Wrap(view)); +} + +void CEF_CALLBACK menu_button_delegate_on_blur( + struct _cef_view_delegate_t* self, cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefMenuButtonDelegateCppToC::Get( + reinterpret_cast(self))->OnBlur( + CefViewCToCpp::Wrap(view)); +} + } // namespace @@ -220,6 +256,8 @@ CefMenuButtonDelegateCppToC::CefMenuButtonDelegateCppToC() { menu_button_delegate_on_parent_view_changed; GetStruct()->base.base.on_child_view_changed = menu_button_delegate_on_child_view_changed; + GetStruct()->base.base.on_focus = menu_button_delegate_on_focus; + GetStruct()->base.base.on_blur = menu_button_delegate_on_blur; } template<> CefRefPtr CefCppToCRefCounted( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK panel_set_group_id(struct _cef_view_t* self, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefPanelCppToC::Get(reinterpret_cast(self))->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK panel_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1060,6 +1087,8 @@ CefPanelCppToC::CefPanelCppToC() { GetStruct()->base.get_window = panel_get_window; GetStruct()->base.get_id = panel_get_id; GetStruct()->base.set_id = panel_set_id; + GetStruct()->base.get_group_id = panel_get_group_id; + GetStruct()->base.set_group_id = panel_set_group_id; GetStruct()->base.get_parent_view = panel_get_parent_view; GetStruct()->base.get_view_for_id = panel_get_view_for_id; GetStruct()->base.set_bounds = panel_set_bounds; diff --git a/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc index c730b0d59..443ab7aa6 100644 --- a/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc @@ -154,6 +154,42 @@ void CEF_CALLBACK panel_delegate_on_child_view_changed( CefViewCToCpp::Wrap(child)); } +void CEF_CALLBACK panel_delegate_on_focus(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefPanelDelegateCppToC::Get(reinterpret_cast( + self))->OnFocus( + CefViewCToCpp::Wrap(view)); +} + +void CEF_CALLBACK panel_delegate_on_blur(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefPanelDelegateCppToC::Get(reinterpret_cast( + self))->OnBlur( + CefViewCToCpp::Wrap(view)); +} + } // namespace @@ -168,6 +204,8 @@ CefPanelDelegateCppToC::CefPanelDelegateCppToC() { panel_delegate_on_parent_view_changed; GetStruct()->base.on_child_view_changed = panel_delegate_on_child_view_changed; + GetStruct()->base.on_focus = panel_delegate_on_focus; + GetStruct()->base.on_blur = panel_delegate_on_blur; } template<> CefRefPtr CefCppToCRefCounted( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK scroll_view_set_group_id(struct _cef_view_t* self, + int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefScrollViewCppToC::Get(reinterpret_cast( + self))->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK scroll_view_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -979,6 +1008,8 @@ CefScrollViewCppToC::CefScrollViewCppToC() { GetStruct()->base.get_window = scroll_view_get_window; GetStruct()->base.get_id = scroll_view_get_id; GetStruct()->base.set_id = scroll_view_set_id; + GetStruct()->base.get_group_id = scroll_view_get_group_id; + GetStruct()->base.set_group_id = scroll_view_set_group_id; GetStruct()->base.get_parent_view = scroll_view_get_parent_view; GetStruct()->base.get_view_for_id = scroll_view_get_view_for_id; GetStruct()->base.set_bounds = scroll_view_set_bounds; diff --git a/libcef_dll/cpptoc/views/textfield_cpptoc.cc b/libcef_dll/cpptoc/views/textfield_cpptoc.cc index 89c942f94..425df515c 100644 --- a/libcef_dll/cpptoc/views/textfield_cpptoc.cc +++ b/libcef_dll/cpptoc/views/textfield_cpptoc.cc @@ -732,6 +732,34 @@ void CEF_CALLBACK textfield_set_id(struct _cef_view_t* self, int id) { id); } +int CEF_CALLBACK textfield_get_group_id(struct _cef_view_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefTextfieldCppToC::Get(reinterpret_cast( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK textfield_set_group_id(struct _cef_view_t* self, + int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTextfieldCppToC::Get(reinterpret_cast(self))->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK textfield_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1361,6 +1389,8 @@ CefTextfieldCppToC::CefTextfieldCppToC() { GetStruct()->base.get_window = textfield_get_window; GetStruct()->base.get_id = textfield_get_id; GetStruct()->base.set_id = textfield_set_id; + GetStruct()->base.get_group_id = textfield_get_group_id; + GetStruct()->base.set_group_id = textfield_set_group_id; GetStruct()->base.get_parent_view = textfield_get_parent_view; GetStruct()->base.get_view_for_id = textfield_get_view_for_id; GetStruct()->base.set_bounds = textfield_set_bounds; diff --git a/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc index b7fde4309..293a80f6f 100644 --- a/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc @@ -202,6 +202,42 @@ void CEF_CALLBACK textfield_delegate_on_child_view_changed( CefViewCToCpp::Wrap(child)); } +void CEF_CALLBACK textfield_delegate_on_focus(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefTextfieldDelegateCppToC::Get(reinterpret_cast( + self))->OnFocus( + CefViewCToCpp::Wrap(view)); +} + +void CEF_CALLBACK textfield_delegate_on_blur(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefTextfieldDelegateCppToC::Get(reinterpret_cast( + self))->OnBlur( + CefViewCToCpp::Wrap(view)); +} + } // namespace @@ -219,6 +255,8 @@ CefTextfieldDelegateCppToC::CefTextfieldDelegateCppToC() { textfield_delegate_on_parent_view_changed; GetStruct()->base.on_child_view_changed = textfield_delegate_on_child_view_changed; + GetStruct()->base.on_focus = textfield_delegate_on_focus; + GetStruct()->base.on_blur = textfield_delegate_on_blur; } template<> CefRefPtr CefCppToCRefCountedGetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK view_set_group_id(struct _cef_view_t* self, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefViewCppToC::Get(self)->SetGroupID( + group_id); +} + struct _cef_view_t* CEF_CALLBACK view_get_parent_view( struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -794,6 +820,8 @@ CefViewCppToC::CefViewCppToC() { GetStruct()->get_window = view_get_window; GetStruct()->get_id = view_get_id; GetStruct()->set_id = view_set_id; + GetStruct()->get_group_id = view_get_group_id; + GetStruct()->set_group_id = view_set_group_id; GetStruct()->get_parent_view = view_get_parent_view; GetStruct()->get_view_for_id = view_get_view_for_id; GetStruct()->set_bounds = view_set_bounds; diff --git a/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc index 74c7ca9f2..959a1f736 100644 --- a/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc @@ -153,6 +153,40 @@ void CEF_CALLBACK view_delegate_on_child_view_changed( CefViewCToCpp::Wrap(child)); } +void CEF_CALLBACK view_delegate_on_focus(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefViewDelegateCppToC::Get(self)->OnFocus( + CefViewCToCpp::Wrap(view)); +} + +void CEF_CALLBACK view_delegate_on_blur(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefViewDelegateCppToC::Get(self)->OnBlur( + CefViewCToCpp::Wrap(view)); +} + } // namespace @@ -165,6 +199,8 @@ CefViewDelegateCppToC::CefViewDelegateCppToC() { GetStruct()->get_height_for_width = view_delegate_get_height_for_width; GetStruct()->on_parent_view_changed = view_delegate_on_parent_view_changed; GetStruct()->on_child_view_changed = view_delegate_on_child_view_changed; + GetStruct()->on_focus = view_delegate_on_focus; + GetStruct()->on_blur = view_delegate_on_blur; } template<> CefRefPtr CefCppToCRefCounted( + self))->GetGroupID(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK window_set_group_id(struct _cef_view_t* self, int group_id) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefWindowCppToC::Get(reinterpret_cast(self))->SetGroupID( + group_id); +} + cef_view_t* CEF_CALLBACK window_get_parent_view(struct _cef_view_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -1621,6 +1648,8 @@ CefWindowCppToC::CefWindowCppToC() { GetStruct()->base.base.get_window = window_get_window; GetStruct()->base.base.get_id = window_get_id; GetStruct()->base.base.set_id = window_set_id; + GetStruct()->base.base.get_group_id = window_get_group_id; + GetStruct()->base.base.set_group_id = window_set_group_id; GetStruct()->base.base.get_parent_view = window_get_parent_view; GetStruct()->base.base.get_view_for_id = window_get_view_for_id; GetStruct()->base.base.set_bounds = window_set_bounds; diff --git a/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc index 81114433e..b8d018b89 100644 --- a/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc @@ -341,6 +341,42 @@ void CEF_CALLBACK window_delegate_on_child_view_changed( CefViewCToCpp::Wrap(child)); } +void CEF_CALLBACK window_delegate_on_focus(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefWindowDelegateCppToC::Get(reinterpret_cast( + self))->OnFocus( + CefViewCToCpp::Wrap(view)); +} + +void CEF_CALLBACK window_delegate_on_blur(struct _cef_view_delegate_t* self, + cef_view_t* view) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + + // Execute + CefWindowDelegateCppToC::Get(reinterpret_cast( + self))->OnBlur( + CefViewCToCpp::Wrap(view)); +} + } // namespace @@ -366,6 +402,8 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() { window_delegate_on_parent_view_changed; GetStruct()->base.base.on_child_view_changed = window_delegate_on_child_view_changed; + GetStruct()->base.base.on_focus = window_delegate_on_focus; + GetStruct()->base.base.on_blur = window_delegate_on_blur; } template<> CefRefPtr CefCppToCRefCounted(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefBrowserViewCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefBrowserViewCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/browser_view_ctocpp.h b/libcef_dll/ctocpp/views/browser_view_ctocpp.h index cf8ec5c45..78aabfffc 100644 --- a/libcef_dll/ctocpp/views/browser_view_ctocpp.h +++ b/libcef_dll/ctocpp/views/browser_view_ctocpp.h @@ -49,6 +49,8 @@ class CefBrowserViewCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc index 61ba96c64..b89d79753 100644 --- a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc @@ -260,6 +260,42 @@ void CefBrowserViewDelegateCToCpp::OnChildViewChanged(CefRefPtr view, CefViewCppToC::Wrap(child)); } +void CefBrowserViewDelegateCToCpp::OnFocus(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_focus(_struct, + CefViewCppToC::Wrap(view)); +} + +void CefBrowserViewDelegateCToCpp::OnBlur(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_blur)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_blur(_struct, + CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h index 267a940ab..21fb803a0 100644 --- a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h @@ -56,6 +56,8 @@ class CefBrowserViewDelegateCToCpp CefRefPtr parent) override; void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) override; + void OnFocus(CefRefPtr view) override; + void OnBlur(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/button_ctocpp.cc b/libcef_dll/ctocpp/views/button_ctocpp.cc index e87e80631..83bb06c6a 100644 --- a/libcef_dll/ctocpp/views/button_ctocpp.cc +++ b/libcef_dll/ctocpp/views/button_ctocpp.cc @@ -303,6 +303,32 @@ void CefButtonCToCpp::SetID(int id) { id); } +int CefButtonCToCpp::GetGroupID() { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefButtonCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefButtonCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/button_ctocpp.h b/libcef_dll/ctocpp/views/button_ctocpp.h index 5f76b62b1..e6eff8d94 100644 --- a/libcef_dll/ctocpp/views/button_ctocpp.h +++ b/libcef_dll/ctocpp/views/button_ctocpp.h @@ -53,6 +53,8 @@ class CefButtonCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc index 3c2da5179..24dbaeb63 100644 --- a/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc @@ -171,6 +171,42 @@ void CefButtonDelegateCToCpp::OnChildViewChanged(CefRefPtr view, CefViewCppToC::Wrap(child)); } +void CefButtonDelegateCToCpp::OnFocus(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_focus(_struct, + CefViewCppToC::Wrap(view)); +} + +void CefButtonDelegateCToCpp::OnBlur(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_blur)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_blur(_struct, + CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/button_delegate_ctocpp.h b/libcef_dll/ctocpp/views/button_delegate_ctocpp.h index cc1d22f18..d794f1203 100644 --- a/libcef_dll/ctocpp/views/button_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/button_delegate_ctocpp.h @@ -44,6 +44,8 @@ class CefButtonDelegateCToCpp CefRefPtr parent) override; void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) override; + void OnFocus(CefRefPtr view) override; + void OnBlur(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_BUTTON_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/label_button_ctocpp.cc b/libcef_dll/ctocpp/views/label_button_ctocpp.cc index 9545b4791..ecc052bae 100644 --- a/libcef_dll/ctocpp/views/label_button_ctocpp.cc +++ b/libcef_dll/ctocpp/views/label_button_ctocpp.cc @@ -488,6 +488,32 @@ void CefLabelButtonCToCpp::SetID(int id) { id); } +int CefLabelButtonCToCpp::GetGroupID() { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefLabelButtonCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefLabelButtonCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/label_button_ctocpp.h b/libcef_dll/ctocpp/views/label_button_ctocpp.h index ea87cad18..cd78a22fc 100644 --- a/libcef_dll/ctocpp/views/label_button_ctocpp.h +++ b/libcef_dll/ctocpp/views/label_button_ctocpp.h @@ -68,6 +68,8 @@ class CefLabelButtonCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/menu_button_ctocpp.cc b/libcef_dll/ctocpp/views/menu_button_ctocpp.cc index cb38cc88a..7d93089ac 100644 --- a/libcef_dll/ctocpp/views/menu_button_ctocpp.cc +++ b/libcef_dll/ctocpp/views/menu_button_ctocpp.cc @@ -522,6 +522,32 @@ void CefMenuButtonCToCpp::SetID(int id) { id); } +int CefMenuButtonCToCpp::GetGroupID() { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefMenuButtonCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefMenuButtonCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/menu_button_ctocpp.h b/libcef_dll/ctocpp/views/menu_button_ctocpp.h index 9da96f426..d9a397a3d 100644 --- a/libcef_dll/ctocpp/views/menu_button_ctocpp.h +++ b/libcef_dll/ctocpp/views/menu_button_ctocpp.h @@ -71,6 +71,8 @@ class CefMenuButtonCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc index fe8abbf6f..c39cea275 100644 --- a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc @@ -191,6 +191,42 @@ void CefMenuButtonDelegateCToCpp::OnChildViewChanged(CefRefPtr view, CefViewCppToC::Wrap(child)); } +void CefMenuButtonDelegateCToCpp::OnFocus(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_focus(_struct, + CefViewCppToC::Wrap(view)); +} + +void CefMenuButtonDelegateCToCpp::OnBlur(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_blur)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_blur(_struct, + CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h index d79daf155..701ea49cf 100644 --- a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h @@ -48,6 +48,8 @@ class CefMenuButtonDelegateCToCpp CefRefPtr parent) override; void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) override; + void OnFocus(CefRefPtr view) override; + void OnBlur(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/panel_ctocpp.cc b/libcef_dll/ctocpp/views/panel_ctocpp.cc index 1e1385715..de2619af0 100644 --- a/libcef_dll/ctocpp/views/panel_ctocpp.cc +++ b/libcef_dll/ctocpp/views/panel_ctocpp.cc @@ -436,6 +436,32 @@ void CefPanelCToCpp::SetID(int id) { id); } +int CefPanelCToCpp::GetGroupID() { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefPanelCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefPanelCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/panel_ctocpp.h b/libcef_dll/ctocpp/views/panel_ctocpp.h index 25c7b44ee..30bfd1d3b 100644 --- a/libcef_dll/ctocpp/views/panel_ctocpp.h +++ b/libcef_dll/ctocpp/views/panel_ctocpp.h @@ -67,6 +67,8 @@ class CefPanelCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc index f4f0c7a8a..4dc1e0bac 100644 --- a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc @@ -153,6 +153,42 @@ void CefPanelDelegateCToCpp::OnChildViewChanged(CefRefPtr view, CefViewCppToC::Wrap(child)); } +void CefPanelDelegateCToCpp::OnFocus(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_focus(_struct, + CefViewCppToC::Wrap(view)); +} + +void CefPanelDelegateCToCpp::OnBlur(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_blur)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_blur(_struct, + CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h index d6916cdba..021d76474 100644 --- a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h @@ -41,6 +41,8 @@ class CefPanelDelegateCToCpp CefRefPtr parent) override; void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) override; + void OnFocus(CefRefPtr view) override; + void OnBlur(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_PANEL_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc b/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc index 18a7484c0..f653d889b 100644 --- a/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc +++ b/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc @@ -345,6 +345,32 @@ void CefScrollViewCToCpp::SetID(int id) { id); } +int CefScrollViewCToCpp::GetGroupID() { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefScrollViewCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefScrollViewCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/scroll_view_ctocpp.h b/libcef_dll/ctocpp/views/scroll_view_ctocpp.h index 48080c41d..d07dacd4e 100644 --- a/libcef_dll/ctocpp/views/scroll_view_ctocpp.h +++ b/libcef_dll/ctocpp/views/scroll_view_ctocpp.h @@ -54,6 +54,8 @@ class CefScrollViewCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/textfield_ctocpp.cc b/libcef_dll/ctocpp/views/textfield_ctocpp.cc index b88b8445b..f650900b9 100644 --- a/libcef_dll/ctocpp/views/textfield_ctocpp.cc +++ b/libcef_dll/ctocpp/views/textfield_ctocpp.cc @@ -681,6 +681,32 @@ void CefTextfieldCToCpp::SetID(int id) { id); } +int CefTextfieldCToCpp::GetGroupID() { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefTextfieldCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefTextfieldCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/textfield_ctocpp.h b/libcef_dll/ctocpp/views/textfield_ctocpp.h index 4fb95b65d..319b44f07 100644 --- a/libcef_dll/ctocpp/views/textfield_ctocpp.h +++ b/libcef_dll/ctocpp/views/textfield_ctocpp.h @@ -79,6 +79,8 @@ class CefTextfieldCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc index 1836c7879..1af92a421 100644 --- a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc @@ -193,6 +193,42 @@ void CefTextfieldDelegateCToCpp::OnChildViewChanged(CefRefPtr view, CefViewCppToC::Wrap(child)); } +void CefTextfieldDelegateCToCpp::OnFocus(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_focus(_struct, + CefViewCppToC::Wrap(view)); +} + +void CefTextfieldDelegateCToCpp::OnBlur(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_blur)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_blur(_struct, + CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h index 83da8fdb5..4e3ac87dd 100644 --- a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h @@ -46,6 +46,8 @@ class CefTextfieldDelegateCToCpp CefRefPtr parent) override; void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) override; + void OnFocus(CefRefPtr view) override; + void OnBlur(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_TEXTFIELD_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/view_ctocpp.cc b/libcef_dll/ctocpp/views/view_ctocpp.cc index ca2c72c66..392ef53c8 100644 --- a/libcef_dll/ctocpp/views/view_ctocpp.cc +++ b/libcef_dll/ctocpp/views/view_ctocpp.cc @@ -229,6 +229,32 @@ void CefViewCToCpp::SetID(int id) { id); } +int CefViewCToCpp::GetGroupID() { + cef_view_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefViewCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefViewCToCpp::GetParentView() { cef_view_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/view_ctocpp.h b/libcef_dll/ctocpp/views/view_ctocpp.h index 8dc568629..9893cdd4d 100644 --- a/libcef_dll/ctocpp/views/view_ctocpp.h +++ b/libcef_dll/ctocpp/views/view_ctocpp.h @@ -56,6 +56,8 @@ class CefViewCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc index 6cfde7b4b..a08a33824 100644 --- a/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc @@ -152,6 +152,40 @@ void CefViewDelegateCToCpp::OnChildViewChanged(CefRefPtr view, CefViewCppToC::Wrap(child)); } +void CefViewDelegateCToCpp::OnFocus(CefRefPtr view) { + cef_view_delegate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, on_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_focus(_struct, + CefViewCppToC::Wrap(view)); +} + +void CefViewDelegateCToCpp::OnBlur(CefRefPtr view) { + cef_view_delegate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, on_blur)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_blur(_struct, + CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/view_delegate_ctocpp.h b/libcef_dll/ctocpp/views/view_delegate_ctocpp.h index 27840d96d..ca491606f 100644 --- a/libcef_dll/ctocpp/views/view_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/view_delegate_ctocpp.h @@ -41,6 +41,8 @@ class CefViewDelegateCToCpp CefRefPtr parent) override; void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) override; + void OnFocus(CefRefPtr view) override; + void OnBlur(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_VIEW_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/window_ctocpp.cc b/libcef_dll/ctocpp/views/window_ctocpp.cc index 857857cc8..80967ccf4 100644 --- a/libcef_dll/ctocpp/views/window_ctocpp.cc +++ b/libcef_dll/ctocpp/views/window_ctocpp.cc @@ -938,6 +938,32 @@ void CefWindowCToCpp::SetID(int id) { id); } +int CefWindowCToCpp::GetGroupID() { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_group_id)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->get_group_id(_struct); + + // Return type: simple + return _retval; +} + +void CefWindowCToCpp::SetGroupID(int group_id) { + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_group_id)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_group_id(_struct, + group_id); +} + CefRefPtr CefWindowCToCpp::GetParentView() { cef_view_t* _struct = reinterpret_cast(GetStruct()); if (CEF_MEMBER_MISSING(_struct, get_parent_view)) diff --git a/libcef_dll/ctocpp/views/window_ctocpp.h b/libcef_dll/ctocpp/views/window_ctocpp.h index ba37ad074..f85c3ff75 100644 --- a/libcef_dll/ctocpp/views/window_ctocpp.h +++ b/libcef_dll/ctocpp/views/window_ctocpp.h @@ -103,6 +103,8 @@ class CefWindowCToCpp CefRefPtr GetWindow() OVERRIDE; int GetID() OVERRIDE; void SetID(int id) OVERRIDE; + int GetGroupID() OVERRIDE; + void SetGroupID(int group_id) OVERRIDE; CefRefPtr GetParentView() OVERRIDE; CefRefPtr GetViewForID(int id) OVERRIDE; void SetBounds(const CefRect& bounds) OVERRIDE; diff --git a/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc index 6b66986d8..87250396a 100644 --- a/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc @@ -331,6 +331,42 @@ void CefWindowDelegateCToCpp::OnChildViewChanged(CefRefPtr view, CefViewCppToC::Wrap(child)); } +void CefWindowDelegateCToCpp::OnFocus(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_focus(_struct, + CefViewCppToC::Wrap(view)); +} + +void CefWindowDelegateCToCpp::OnBlur(CefRefPtr view) { + cef_view_delegate_t* _struct = reinterpret_cast( + GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_blur)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_blur(_struct, + CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/window_delegate_ctocpp.h b/libcef_dll/ctocpp/views/window_delegate_ctocpp.h index 9d0ef514c..980e7f38a 100644 --- a/libcef_dll/ctocpp/views/window_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/window_delegate_ctocpp.h @@ -55,6 +55,8 @@ class CefWindowDelegateCToCpp CefRefPtr parent) override; void OnChildViewChanged(CefRefPtr view, bool added, CefRefPtr child) override; + void OnFocus(CefRefPtr view) override; + void OnBlur(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_ diff --git a/tests/cefclient/browser/views_window.cc b/tests/cefclient/browser/views_window.cc index 87881154e..ca26bc139 100644 --- a/tests/cefclient/browser/views_window.cc +++ b/tests/cefclient/browser/views_window.cc @@ -34,6 +34,8 @@ enum ControlIds { ID_RELOAD_BUTTON, ID_URL_TEXTFIELD, ID_MENU_BUTTON, + ID_TOP_FILE_MENU_BUTTON, + ID_TOP_TEST_MENU_BUTTON, }; typedef std::vector > LabelButtons; @@ -60,6 +62,30 @@ void MakeButtonsSameSize(const LabelButtons& buttons) { } } +void AddTestMenuItems(CefRefPtr test_menu) { + test_menu->AddItem(ID_TESTS_GETSOURCE, "Get Source"); + test_menu->AddItem(ID_TESTS_GETTEXT, "Get Text"); + test_menu->AddItem(ID_TESTS_WINDOW_NEW, "New Window"); + test_menu->AddItem(ID_TESTS_WINDOW_POPUP, "Popup Window"); + test_menu->AddItem(ID_TESTS_REQUEST, "Request"); + test_menu->AddItem(ID_TESTS_PLUGIN_INFO, "Plugin Info"); + test_menu->AddItem(ID_TESTS_ZOOM_IN, "Zoom In"); + test_menu->AddItem(ID_TESTS_ZOOM_OUT, "Zoom Out"); + test_menu->AddItem(ID_TESTS_ZOOM_RESET, "Zoom Reset"); + test_menu->AddItem(ID_TESTS_TRACING_BEGIN, "Begin Tracing"); + test_menu->AddItem(ID_TESTS_TRACING_END, "End Tracing"); + test_menu->AddItem(ID_TESTS_PRINT, "Print"); + test_menu->AddItem(ID_TESTS_PRINT_TO_PDF, "Print to PDF"); + test_menu->AddItem(ID_TESTS_OTHER_TESTS, "Other Tests"); +} + +void AddFileMenuItems(CefRefPtr file_menu, int offset) { + file_menu->AddItem(ID_QUIT, "E&xit"); + + // Show the accelerator shortcut text in the menu. + file_menu->SetAcceleratorAt(offset, 'X', false, false, true); +} + } // namespace // static @@ -211,13 +237,8 @@ void ViewsWindow::TakeFocus(bool next) { if (!window_ || !with_controls_) return; - if (next) { - // Focus is moving forwards (tab). Give focus to the URL textfield. - window_->GetViewForID(ID_URL_TEXTFIELD)->RequestFocus(); - } else { - // Focus is moving backwards (tab+shift). Give focus to the menu button. - window_->GetViewForID(ID_MENU_BUTTON)->RequestFocus(); - } + // Give focus to the URL textfield. + window_->GetViewForID(ID_URL_TEXTFIELD)->RequestFocus(); } bool ViewsWindow::OnPopupBrowserViewCreated( @@ -280,9 +301,23 @@ void ViewsWindow::OnMenuButtonPressed(CefRefPtr menu_button, const CefPoint& screen_point) { CEF_REQUIRE_UI_THREAD(); DCHECK(with_controls_); - DCHECK_EQ(ID_MENU_BUTTON, menu_button->GetID()); - menu_button->ShowMenu(menu_model_, screen_point, CEF_MENU_ANCHOR_TOPRIGHT); + CefRefPtr menu_model; + + switch (menu_button->GetID()) { + case ID_MENU_BUTTON: + menu_model = button_menu_model_; + break; + case ID_TOP_FILE_MENU_BUTTON: + menu_model = file_menu_model_; + break; + case ID_TOP_TEST_MENU_BUTTON: + menu_model = test_menu_model_; + break; + } + + if (menu_model) + menu_button->ShowMenu(menu_model, screen_point, CEF_MENU_ANCHOR_TOPRIGHT); } void ViewsWindow::ExecuteCommand(CefRefPtr menu_model, @@ -386,7 +421,9 @@ void ViewsWindow::OnWindowDestroyed(CefRefPtr window) { delegate_->OnViewsWindowDestroyed(this); browser_view_ = NULL; - menu_model_ = NULL; + button_menu_model_ = NULL; + file_menu_model_ = NULL; + test_menu_model_ = NULL; window_ = NULL; } @@ -424,8 +461,8 @@ bool ViewsWindow::OnKeyEvent(CefRefPtr window, return false; if (event.type == KEYEVENT_RAWKEYDOWN && event.windows_key_code == VK_MENU) { - // ALT key is pressed. Give focus to the menu button. - window_->GetViewForID(ID_MENU_BUTTON)->RequestFocus(); + // ALT key is pressed. Make the menu buttons focusable. + SetMenuFocusable(true); return true; } @@ -441,10 +478,28 @@ CefSize ViewsWindow::GetMinimumSize(CefRefPtr view) { return CefSize(); } +void ViewsWindow::OnFocus(CefRefPtr view) { + CEF_REQUIRE_UI_THREAD(); + + // When focus leaves the menu buttons make them unfocusable. + if (menu_has_focus_) { + const int view_id = view->GetID(); + if (with_top_menu_) { + if (view_id != ID_TOP_FILE_MENU_BUTTON && + view_id != ID_TOP_TEST_MENU_BUTTON) { + SetMenuFocusable(false); + } + } else if (view_id != ID_MENU_BUTTON) { + SetMenuFocusable(false); + } + } +} + ViewsWindow::ViewsWindow(Delegate* delegate, CefRefPtr browser_view) : delegate_(delegate), - with_controls_(false) { + with_controls_(false), + menu_has_focus_(false) { DCHECK(delegate_); if (browser_view) SetBrowserView(browser_view); @@ -452,6 +507,7 @@ ViewsWindow::ViewsWindow(Delegate* delegate, CefRefPtr command_line = CefCommandLine::GetGlobalCommandLine(); frameless_ = command_line->HasSwitch(switches::kHideFrame); + with_top_menu_ = command_line->HasSwitch(switches::kShowTopMenu); } void ViewsWindow::SetBrowserView(CefRefPtr browser_view) { @@ -463,29 +519,31 @@ void ViewsWindow::SetBrowserView(CefRefPtr browser_view) { } void ViewsWindow::CreateMenuModel() { - menu_model_ = CefMenuModel::CreateMenuModel(this); + // Create the menu button model. + button_menu_model_ = CefMenuModel::CreateMenuModel(this); + CefRefPtr test_menu = + button_menu_model_->AddSubMenu(0, "&Tests"); + AddTestMenuItems(test_menu); + AddFileMenuItems(button_menu_model_, 1); - // Create the test menu. - CefRefPtr test_menu = menu_model_->AddSubMenu(0, "&Tests"); - test_menu->AddItem(ID_TESTS_GETSOURCE, "Get Source"); - test_menu->AddItem(ID_TESTS_GETTEXT, "Get Text"); - test_menu->AddItem(ID_TESTS_WINDOW_NEW, "New Window"); - test_menu->AddItem(ID_TESTS_WINDOW_POPUP, "Popup Window"); - test_menu->AddItem(ID_TESTS_REQUEST, "Request"); - test_menu->AddItem(ID_TESTS_PLUGIN_INFO, "Plugin Info"); - test_menu->AddItem(ID_TESTS_ZOOM_IN, "Zoom In"); - test_menu->AddItem(ID_TESTS_ZOOM_OUT, "Zoom Out"); - test_menu->AddItem(ID_TESTS_ZOOM_RESET, "Zoom Reset"); - test_menu->AddItem(ID_TESTS_TRACING_BEGIN, "Begin Tracing"); - test_menu->AddItem(ID_TESTS_TRACING_END, "End Tracing"); - test_menu->AddItem(ID_TESTS_PRINT, "Print"); - test_menu->AddItem(ID_TESTS_PRINT_TO_PDF, "Print to PDF"); - test_menu->AddItem(ID_TESTS_OTHER_TESTS, "Other Tests"); + if (with_top_menu_) { + // Create the top menu model. + file_menu_model_ = CefMenuModel::CreateMenuModel(this); + AddFileMenuItems(file_menu_model_, 0); + test_menu_model_ = CefMenuModel::CreateMenuModel(this); + AddTestMenuItems(test_menu_model_); + } +} - menu_model_->AddItem(ID_QUIT, "E&xit"); - - // Show the accelerator shortcut text in the menu. - menu_model_->SetAcceleratorAt(1, 'X', false, false, true); +CefRefPtr ViewsWindow::CreateTopMenuButton( + const std::string& label, int id) { + CefRefPtr button = + CefMenuButton::CreateMenuButton(this, label, false, false); + button->SetID(id); + // Assign a group ID to allow focus traversal between top menu buttons using + // the arrow keys. + button->SetGroupID(1); + return button; } CefRefPtr ViewsWindow::CreateBrowseButton( @@ -503,6 +561,27 @@ void ViewsWindow::AddControls() { // Create the MenuModel that will be displayed via the menu button. CreateMenuModel(); + CefRefPtr top_menu_panel; + if (with_top_menu_) { + // Create the top menu buttons. + CefRefPtr top_file_menu_button = + CreateTopMenuButton("File", ID_TOP_FILE_MENU_BUTTON); + CefRefPtr top_test_menu_button = + CreateTopMenuButton("Test", ID_TOP_TEST_MENU_BUTTON); + + // Create the top menu panel. + top_menu_panel = CefPanel::CreatePanel(NULL); + + // Use a horizontal box layout for |top_panel|. + CefBoxLayoutSettings top_panel_layout_settings; + top_panel_layout_settings.horizontal = true; + CefRefPtr top_panel_layout = + top_menu_panel->SetToBoxLayout(top_panel_layout_settings); + + top_menu_panel->AddChildView(top_file_menu_button); + top_menu_panel->AddChildView(top_test_menu_button); + } + // Create the browse buttons. LabelButtons browse_buttons; browse_buttons.push_back(CreateBrowseButton("Back", ID_BACK_BUTTON)); @@ -522,8 +601,6 @@ void ViewsWindow::AddControls() { menu_button->SetImage(CEF_BUTTON_STATE_NORMAL, LoadImageIcon("menu_icon")); // Override the default minimum size. menu_button->SetMinimumSize(CefSize(0, 0)); - // Menu button must be focusable for keyboard access to work. - menu_button->SetFocusable(true); // Create the top panel. CefRefPtr top_panel = CefPanel::CreatePanel(NULL); @@ -551,6 +628,8 @@ void ViewsWindow::AddControls() { window_->SetToBoxLayout(window_layout_settings); // Add the top panel and browser view to |window|. + if (top_menu_panel) + window_->AddChildView(top_menu_panel); window_->AddChildView(top_panel); window_->AddChildView(browser_view_); @@ -570,7 +649,9 @@ void ViewsWindow::AddControls() { const int min_width = browse_buttons[0]->GetBounds().width * 4 + menu_button->GetBounds().width + 100; // Minimum window height is the hight of the top toolbar plus some extra. - const int min_height = top_panel->GetBounds().height + 100; + int min_height = top_panel->GetBounds().height + 100; + if (top_menu_panel) + min_height += top_menu_panel->GetBounds().height; minimum_window_size_ = CefSize(min_width, min_height); } @@ -584,6 +665,30 @@ void ViewsWindow::AddAccelerators() { window_->SetAccelerator(ID_QUIT, 'X', false, false, true); } +void ViewsWindow::SetMenuFocusable(bool focusable) { + if (!window_ || !with_controls_) + return; + + if (with_top_menu_) { + window_->GetViewForID(ID_TOP_FILE_MENU_BUTTON)->SetFocusable(focusable); + window_->GetViewForID(ID_TOP_TEST_MENU_BUTTON)->SetFocusable(focusable); + + if (focusable) { + // Give focus to top file menu button. + window_->GetViewForID(ID_TOP_FILE_MENU_BUTTON)->RequestFocus(); + } + } else { + window_->GetViewForID(ID_MENU_BUTTON)->SetFocusable(focusable); + + if (focusable) { + // Give focus to menu button. + window_->GetViewForID(ID_MENU_BUTTON)->RequestFocus(); + } + } + + menu_has_focus_ = focusable; +} + void ViewsWindow::EnableView(int id, bool enable) { if (!window_) return; diff --git a/tests/cefclient/browser/views_window.h b/tests/cefclient/browser/views_window.h index 39f3d07a0..6b99a2807 100644 --- a/tests/cefclient/browser/views_window.h +++ b/tests/cefclient/browser/views_window.h @@ -117,7 +117,8 @@ class ViewsWindow : public CefBrowserViewDelegate, const CefKeyEvent& event) OVERRIDE; // CefViewDelegate methods: - CefSize GetMinimumSize(CefRefPtr view) override; + CefSize GetMinimumSize(CefRefPtr view) OVERRIDE; + void OnFocus(CefRefPtr view) OVERRIDE; private: // |delegate| is guaranteed to outlive this object. @@ -129,6 +130,8 @@ class ViewsWindow : public CefBrowserViewDelegate, // Create controls. void CreateMenuModel(); + CefRefPtr CreateTopMenuButton(const std::string& label, + int id); CefRefPtr CreateBrowseButton(const std::string& label, int id); @@ -138,6 +141,9 @@ class ViewsWindow : public CefBrowserViewDelegate, // Add keyboard accelerators to the Window. void AddAccelerators(); + // Control whether the top menu butons are focusable. + void SetMenuFocusable(bool focusable); + // Enable or disable a view by |id|. void EnableView(int id, bool enable); @@ -148,9 +154,13 @@ class ViewsWindow : public CefBrowserViewDelegate, CefRefPtr browser_view_; bool frameless_; bool with_controls_; + bool with_top_menu_; CefRefPtr window_; - CefRefPtr menu_model_; + CefRefPtr button_menu_model_; + CefRefPtr file_menu_model_; + CefRefPtr test_menu_model_; + bool menu_has_focus_; CefSize minimum_window_size_; diff --git a/tests/shared/common/client_switches.cc b/tests/shared/common/client_switches.cc index b6d255e37..1b9411ddd 100644 --- a/tests/shared/common/client_switches.cc +++ b/tests/shared/common/client_switches.cc @@ -34,6 +34,7 @@ const char kFilterURL[] = "filter-url"; const char kUseViews[] = "use-views"; const char kHideFrame[] = "hide-frame"; const char kHideControls[] = "hide-controls"; +const char kShowTopMenu[] = "show-top-menu"; const char kWidevineCdmPath[] = "widevine-cdm-path"; const char kSslClientCertificate[] = "ssl-client-certificate"; diff --git a/tests/shared/common/client_switches.h b/tests/shared/common/client_switches.h index 288998cc1..6ce695633 100644 --- a/tests/shared/common/client_switches.h +++ b/tests/shared/common/client_switches.h @@ -28,6 +28,7 @@ extern const char kFilterURL[]; extern const char kUseViews[]; extern const char kHideFrame[]; extern const char kHideControls[]; +extern const char kShowTopMenu[]; extern const char kWidevineCdmPath[]; extern const char kSslClientCertificate[];