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

Side by Side Diff: views/events/event.h

Issue 8511061: Move GetCharacterFromKeyCode from views::KeyEvent to ui/base/keycodes/keyboard_code_conversion.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win_shared builder Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef VIEWS_EVENTS_EVENT_H_ 5 #ifndef VIEWS_EVENTS_EVENT_H_
6 #define VIEWS_EVENTS_EVENT_H_ 6 #define VIEWS_EVENTS_EVENT_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 // Gets the character generated by this key event. It only supports Unicode 328 // Gets the character generated by this key event. It only supports Unicode
329 // BMP characters. 329 // BMP characters.
330 uint16 GetCharacter() const; 330 uint16 GetCharacter() const;
331 331
332 // Gets the character generated by this key event ignoring concurrently-held 332 // Gets the character generated by this key event ignoring concurrently-held
333 // modifiers (except shift). 333 // modifiers (except shift).
334 uint16 GetUnmodifiedCharacter() const; 334 uint16 GetUnmodifiedCharacter() const;
335 335
336 private: 336 private:
337 // A helper function to get the character generated by a key event in a 337 // See GetCharacterFromKeyCode in ui/base/keycodes/keyboard_code_conversion.h
338 // platform independent way. It supports control characters as well. 338 // for details.
339 // It assumes a US keyboard layout is used, so it may only be used when there
340 // is no native event or no better way to get the character.
341 // For example, if a virtual keyboard implementation can only generate key
342 // events with key_code and flags information, then there is no way for us to
343 // determine the actual character that should be generate by the key. Because
344 // a key_code only represents a physical key on the keyboard, it has nothing
345 // to do with the actual character printed on that key. In such case, the only
346 // thing we can do is to assume that we are using a US keyboard and get the
347 // character according to US keyboard layout definition.
348 // If a virtual keyboard implementation wants to support other keyboard
349 // layouts, that may generate different text for a certain key than on a US
350 // keyboard, a special native event object should be introduced to carry extra
351 // information to help determine the correct character.
352 // Take XKeyEvent as an example, it contains not only keycode and modifier
353 // flags but also group and other extra XKB information to help determine the
354 // correct character. That's why we can use XLookupString() function to get
355 // the correct text generated by a X key event (See how is GetCharacter()
356 // implemented in event_x.cc).
357 // TODO(suzhe): define a native event object for virtual keyboard. We may need
358 // to take the actual feature requirement into account.
359 static uint16 GetCharacterFromKeyCode(ui::KeyboardCode key_code, int flags); 339 static uint16 GetCharacterFromKeyCode(ui::KeyboardCode key_code, int flags);
360 340
361 ui::KeyboardCode key_code_; 341 ui::KeyboardCode key_code_;
362 342
363 uint16 character_; 343 uint16 character_;
364 uint16 unmodified_character_; 344 uint16 unmodified_character_;
365 345
366 DISALLOW_COPY_AND_ASSIGN(KeyEvent); 346 DISALLOW_COPY_AND_ASSIGN(KeyEvent);
367 }; 347 };
368 348
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 410
431 // Bitmask of supported ui::DragDropTypes::DragOperation by the source. 411 // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
432 int source_operations_; 412 int source_operations_;
433 413
434 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent); 414 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
435 }; 415 };
436 416
437 } // namespace views 417 } // namespace views
438 418
439 #endif // VIEWS_EVENTS_EVENT_H_ 419 #endif // VIEWS_EVENTS_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698