| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 GtkWidget* widget, | 350 GtkWidget* widget, |
| 351 GdkEventKey* event, | 351 GdkEventKey* event, |
| 352 NativeTextfieldGtk* textfield) { | 352 NativeTextfieldGtk* textfield) { |
| 353 return textfield->OnKeyPressEvent(event); | 353 return textfield->OnKeyPressEvent(event); |
| 354 } | 354 } |
| 355 | 355 |
| 356 gboolean NativeTextfieldGtk::OnKeyPressEvent(GdkEventKey* event) { | 356 gboolean NativeTextfieldGtk::OnKeyPressEvent(GdkEventKey* event) { |
| 357 Textfield::Controller* controller = textfield_->GetController(); | 357 Textfield::Controller* controller = textfield_->GetController(); |
| 358 if (controller) { | 358 if (controller) { |
| 359 KeyEvent key_event(event); | 359 KeyEvent key_event(event); |
| 360 Textfield::Keystroke ks(&key_event); | 360 return controller->HandleKeyEvent(textfield_, key_event); |
| 361 return controller->HandleKeystroke(textfield_, ks); | |
| 362 } | 361 } |
| 363 return false; | 362 return false; |
| 364 } | 363 } |
| 365 | 364 |
| 366 // static | 365 // static |
| 367 gboolean NativeTextfieldGtk::OnActivateHandler( | 366 gboolean NativeTextfieldGtk::OnActivateHandler( |
| 368 GtkWidget* widget, | 367 GtkWidget* widget, |
| 369 NativeTextfieldGtk* textfield) { | 368 NativeTextfieldGtk* textfield) { |
| 370 return textfield->OnActivate(); | 369 return textfield->OnActivate(); |
| 371 } | 370 } |
| 372 | 371 |
| 373 gboolean NativeTextfieldGtk::OnActivate() { | 372 gboolean NativeTextfieldGtk::OnActivate() { |
| 374 GdkEvent* event = gtk_get_current_event(); | 373 GdkEvent* event = gtk_get_current_event(); |
| 375 if (!event || event->type != GDK_KEY_PRESS) | 374 if (!event || event->type != GDK_KEY_PRESS) |
| 376 return false; | 375 return false; |
| 377 | 376 |
| 378 GdkEventKey* key_event = reinterpret_cast<GdkEventKey*>(event); | 377 GdkEventKey* key_event = reinterpret_cast<GdkEventKey*>(event); |
| 379 gboolean handled = false; | 378 gboolean handled = false; |
| 380 | 379 |
| 381 Textfield::Controller* controller = textfield_->GetController(); | 380 Textfield::Controller* controller = textfield_->GetController(); |
| 382 if (controller) { | 381 if (controller) { |
| 383 KeyEvent views_key_event(key_event); | 382 KeyEvent views_key_event(key_event); |
| 384 Textfield::Keystroke ks(&views_key_event); | 383 handled = controller->HandleKeyEvent(textfield_, views_key_event); |
| 385 handled = controller->HandleKeystroke(textfield_, ks); | |
| 386 } | 384 } |
| 387 | 385 |
| 388 WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget()); | 386 WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget()); |
| 389 if (!handled && widget) | 387 if (!handled && widget) |
| 390 handled = widget->HandleKeyboardEvent(key_event); | 388 handled = widget->HandleKeyboardEvent(key_event); |
| 391 | 389 |
| 392 return handled; | 390 return handled; |
| 393 } | 391 } |
| 394 | 392 |
| 395 // static | 393 // static |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 G_CALLBACK(OnChangedHandler), this); | 438 G_CALLBACK(OnChangedHandler), this); |
| 441 } | 439 } |
| 442 g_signal_connect_after(widget, "key-press-event", | 440 g_signal_connect_after(widget, "key-press-event", |
| 443 G_CALLBACK(OnKeyPressEventHandler), this); | 441 G_CALLBACK(OnKeyPressEventHandler), this); |
| 444 // In order to properly trigger Accelerators bound to VKEY_RETURN, we need to | 442 // In order to properly trigger Accelerators bound to VKEY_RETURN, we need to |
| 445 // send an event when the widget gets the activate signal. | 443 // send an event when the widget gets the activate signal. |
| 446 g_signal_connect(widget, "activate", G_CALLBACK(OnActivateHandler), this); | 444 g_signal_connect(widget, "activate", G_CALLBACK(OnActivateHandler), this); |
| 447 } | 445 } |
| 448 | 446 |
| 449 } // namespace views | 447 } // namespace views |
| OLD | NEW |