Index: ui/views/examples/label_example.cc |
diff --git a/ui/views/examples/label_example.cc b/ui/views/examples/label_example.cc |
index 4255e71679c88747698b89989ab2573d26977be9..0b6b344c3663237c289319208d8381dc1cbb1712 100644 |
--- a/ui/views/examples/label_example.cc |
+++ b/ui/views/examples/label_example.cc |
@@ -132,6 +132,8 @@ void LabelExample::ButtonPressed(Button* button, const ui::Event& event) { |
shadows.push_back(gfx::ShadowValue(gfx::Vector2d(2, 2), 0, SK_ColorGRAY)); |
} |
custom_label_->SetShadows(shadows); |
+ } else if (button == text_selection_) { |
+ custom_label_->SetSelectable(text_selection_->checked()); |
} |
custom_label_->parent()->parent()->Layout(); |
custom_label_->SchedulePaint(); |
@@ -186,6 +188,8 @@ void LabelExample::AddCustomLabel(View* container) { |
0, GridLayout::USE_PREF, 0, 0); |
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, |
0, GridLayout::USE_PREF, 0, 0); |
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, |
+ GridLayout::USE_PREF, 0, 0); |
layout->StartRow(0, 1); |
multiline_ = new Checkbox(base::ASCIIToUTF16("Multiline")); |
multiline_->set_listener(this); |
@@ -193,6 +197,9 @@ void LabelExample::AddCustomLabel(View* container) { |
shadows_ = new Checkbox(base::ASCIIToUTF16("Shadows")); |
shadows_->set_listener(this); |
layout->AddView(shadows_); |
+ text_selection_ = new Checkbox(base::ASCIIToUTF16("Text selection")); |
+ text_selection_->set_listener(this); |
+ layout->AddView(text_selection_); |
layout->AddPaddingRow(0, 8); |
column_set = layout->AddColumnSet(2); |
@@ -205,6 +212,13 @@ void LabelExample::AddCustomLabel(View* container) { |
custom_label_->SetText(textfield_->text()); |
layout->AddView(custom_label_); |
+ // Disable the text selection checkbox if |custom_label_| does not support |
+ // text selection. |
+ if (custom_label_->SetSelectable(true)) |
+ text_selection_->SetChecked(true); |
+ else |
+ text_selection_->SetEnabled(false); |
+ |
container->AddChildView(control_container); |
} |