Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: ui/views/view.h

Issue 108063004: Give up focus if the focused view becomes unfocusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Return early if not focused Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/view.h
diff --git a/ui/views/view.h b/ui/views/view.h
index 858fde3ac699d3e5ebe457efff1245bdfc05fda9..bdf4813deb37d2dcc5c27b63ed0379f14ad8e483 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -271,7 +271,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// as with Labels).
virtual int GetHeightForWidth(int w) const;
- // Set whether this view is visible. Painting is scheduled as needed.
+ // Sets whether this view is visible. Painting is scheduled as needed. Also,
+ // clears focus if the focused view or one of its ancestors is set to be
+ // hidden.
virtual void SetVisible(bool visible);
// Return whether a view is visible
@@ -282,7 +284,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Set whether this view is enabled. A disabled view does not receive keyboard
// or mouse inputs. If |enabled| differs from the current value, SchedulePaint
- // is invoked.
+ // is invoked. Also, clears focus if the focused view is disabled.
void SetEnabled(bool enabled);
// Returns whether the view is enabled.
@@ -768,20 +770,22 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// IMPORTANT NOTE: loops in the focus hierarchy are not supported.
void SetNextFocusableView(View* view);
- // Sets whether this view is capable of taking focus.
+ // Sets whether this view is capable of taking focus. It will clear focus if
+ // the focused view is set to be non-focusable.
// Note that this is false by default so that a view used as a container does
// not get the focus.
void SetFocusable(bool focusable);
// Returns true if this view is |focusable_|, |enabled_| and drawn.
- virtual bool IsFocusable() const;
+ bool IsFocusable() const;
// Return whether this view is focusable when the user requires full keyboard
// access, even though it may not be normally focusable.
bool IsAccessibilityFocusable() const;
// Set whether this view can be made focusable if the user requires
- // full keyboard access, even though it's not normally focusable.
+ // full keyboard access, even though it's not normally focusable. It will
+ // clear focus if the focused view is set to be non-focusable.
// Note that this is false by default.
void SetAccessibilityFocusable(bool accessibility_focusable);
@@ -1412,6 +1416,10 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// to the view at the specified index.
void InitFocusSiblings(View* view, int index);
+ // Helper function to advance focus, in case the currently focused view has
+ // become unfocusable.
+ void AdvanceFocusIfNecessary();
+
// System events -------------------------------------------------------------
// Used to propagate theme changed notifications from the root view to all
« no previous file with comments | « ui/views/focus/focus_manager.cc ('k') | ui/views/view.cc » ('j') | ui/views/view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698