| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <gdk/gdkkeysyms.h> | 5 #include <gdk/gdkkeysyms.h> |
| 6 #include <gtk/gtk.h> | 6 #include <gtk/gtk.h> |
| 7 | 7 |
| 8 #include "views/controls/textfield/native_textfield_gtk.h" | 8 #include "views/controls/textfield/native_textfield_gtk.h" |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 bool NativeTextfieldGtk::HandleKeyReleased(const views::KeyEvent& e) { | 369 bool NativeTextfieldGtk::HandleKeyReleased(const views::KeyEvent& e) { |
| 370 return false; | 370 return false; |
| 371 } | 371 } |
| 372 | 372 |
| 373 void NativeTextfieldGtk::HandleFocus() { | 373 void NativeTextfieldGtk::HandleFocus() { |
| 374 } | 374 } |
| 375 | 375 |
| 376 void NativeTextfieldGtk::HandleBlur() { | 376 void NativeTextfieldGtk::HandleBlur() { |
| 377 } | 377 } |
| 378 | 378 |
| 379 TextInputClient* NativeTextfieldGtk::GetTextInputClient() { |
| 380 return NULL; |
| 381 } |
| 382 |
| 379 // static | 383 // static |
| 380 gboolean NativeTextfieldGtk::OnKeyPressEventHandler( | 384 gboolean NativeTextfieldGtk::OnKeyPressEventHandler( |
| 381 GtkWidget* widget, | 385 GtkWidget* widget, |
| 382 GdkEventKey* event, | 386 GdkEventKey* event, |
| 383 NativeTextfieldGtk* textfield) { | 387 NativeTextfieldGtk* textfield) { |
| 384 return textfield->OnKeyPressEvent(event); | 388 return textfield->OnKeyPressEvent(event); |
| 385 } | 389 } |
| 386 | 390 |
| 387 gboolean NativeTextfieldGtk::OnKeyPressEvent(GdkEventKey* event) { | 391 gboolean NativeTextfieldGtk::OnKeyPressEvent(GdkEventKey* event) { |
| 388 TextfieldController* controller = textfield_->GetController(); | 392 TextfieldController* controller = textfield_->GetController(); |
| 389 if (controller) { | 393 if (controller) { |
| 390 KeyEvent key_event(reinterpret_cast<GdkEvent*>(event)); | 394 KeyEvent key_event(reinterpret_cast<GdkEvent*>(event)); |
| 391 return controller->HandleKeyEvent(textfield_, key_event); | 395 return controller->HandleKeyEvent(textfield_, key_event); |
| 392 } | 396 } |
| 393 return false; | 397 return false; |
| 394 } | 398 } |
| 395 | 399 |
| 396 // static | 400 // static |
| 397 gboolean NativeTextfieldGtk::OnActivateHandler( | 401 gboolean NativeTextfieldGtk::OnActivateHandler( |
| 398 GtkWidget* widget, | 402 GtkWidget* widget, |
| 399 NativeTextfieldGtk* textfield) { | 403 NativeTextfieldGtk* textfield) { |
| 400 return textfield->OnActivate(); | 404 return textfield->OnActivate(); |
| 401 } | 405 } |
| 402 | 406 |
| 403 gboolean NativeTextfieldGtk::OnActivate() { | 407 gboolean NativeTextfieldGtk::OnActivate() { |
| 404 GdkEvent* event = gtk_get_current_event(); | 408 GdkEvent* event = gtk_get_current_event(); |
| 405 if (!event || event->type != GDK_KEY_PRESS) | 409 if (!event || event->type != GDK_KEY_PRESS) |
| 406 return false; | 410 return false; |
| 407 | 411 |
| 408 GdkEventKey* key_event = reinterpret_cast<GdkEventKey*>(event); | 412 KeyEvent views_key_event(event); |
| 409 gboolean handled = false; | 413 gboolean handled = false; |
| 410 | 414 |
| 411 TextfieldController* controller = textfield_->GetController(); | 415 TextfieldController* controller = textfield_->GetController(); |
| 412 if (controller) { | 416 if (controller) |
| 413 KeyEvent views_key_event(event); | |
| 414 handled = controller->HandleKeyEvent(textfield_, views_key_event); | 417 handled = controller->HandleKeyEvent(textfield_, views_key_event); |
| 415 } | |
| 416 | 418 |
| 417 WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget()); | 419 WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget()); |
| 418 if (!handled && widget) | 420 if (!handled && widget) |
| 419 handled = widget->HandleKeyboardEvent(key_event); | 421 handled = widget->HandleKeyboardEvent(views_key_event); |
| 420 | 422 |
| 421 return handled; | 423 return handled; |
| 422 } | 424 } |
| 423 | 425 |
| 424 // static | 426 // static |
| 425 gboolean NativeTextfieldGtk::OnChangedHandler( | 427 gboolean NativeTextfieldGtk::OnChangedHandler( |
| 426 GtkWidget* widget, | 428 GtkWidget* widget, |
| 427 NativeTextfieldGtk* textfield) { | 429 NativeTextfieldGtk* textfield) { |
| 428 return textfield->OnChanged(); | 430 return textfield->OnChanged(); |
| 429 } | 431 } |
| 430 | 432 |
| 431 gboolean NativeTextfieldGtk::OnChanged() { | 433 gboolean NativeTextfieldGtk::OnChanged() { |
| 432 textfield_->SyncText(); | 434 textfield_->SyncText(); |
| 433 TextfieldController* controller = textfield_->GetController(); | |
| 434 if (controller) | |
| 435 controller->ContentsChanged(textfield_, GetText()); | |
| 436 textfield_->GetWidget()->NotifyAccessibilityEvent( | 435 textfield_->GetWidget()->NotifyAccessibilityEvent( |
| 437 textfield_, ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true); | 436 textfield_, ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true); |
| 438 return false; | 437 return false; |
| 439 } | 438 } |
| 440 | 439 |
| 441 // static | 440 // static |
| 442 gboolean NativeTextfieldGtk::OnMoveCursorHandler( | 441 gboolean NativeTextfieldGtk::OnMoveCursorHandler( |
| 443 GtkWidget* widget, | 442 GtkWidget* widget, |
| 444 GtkMovementStep step, | 443 GtkMovementStep step, |
| 445 gint count, | 444 gint count, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 // static | 520 // static |
| 522 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 521 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| 523 Textfield* field) { | 522 Textfield* field) { |
| 524 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { | 523 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { |
| 525 return new NativeTextfieldViews(field); | 524 return new NativeTextfieldViews(field); |
| 526 } | 525 } |
| 527 return new NativeTextfieldGtk(field); | 526 return new NativeTextfieldGtk(field); |
| 528 } | 527 } |
| 529 | 528 |
| 530 } // namespace views | 529 } // namespace views |
| OLD | NEW |