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

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

Issue 6713027: Add GetCharacter() and GetUnmodifiedCharacter() methods to views::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment. Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | views/events/event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // 282 //
283 //////////////////////////////////////////////////////////////////////////////// 283 ////////////////////////////////////////////////////////////////////////////////
284 class KeyEvent : public Event { 284 class KeyEvent : public Event {
285 public: 285 public:
286 explicit KeyEvent(NativeEvent native_event); 286 explicit KeyEvent(NativeEvent native_event);
287 KeyEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native); 287 KeyEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native);
288 288
289 // Creates a new KeyEvent synthetically (i.e. not in response to an input 289 // Creates a new KeyEvent synthetically (i.e. not in response to an input
290 // event from the host environment). This is typically only used in testing as 290 // event from the host environment). This is typically only used in testing as
291 // some metadata obtainable from the underlying native event is not present. 291 // some metadata obtainable from the underlying native event is not present.
292 // TODO(beng): see if we can kill this. 292 // It's also used by input methods to fabricate keyboard events.
293 KeyEvent(ui::EventType type, 293 KeyEvent(ui::EventType type,
294 ui::KeyboardCode key_code, 294 ui::KeyboardCode key_code,
295 int event_flags); 295 int event_flags);
296 296
297 ui::KeyboardCode key_code() const { return key_code_; } 297 ui::KeyboardCode key_code() const { return key_code_; }
298 298
299 // Gets the character generated by this key event. It only supports Unicode
300 // BMP characters.
301 uint16 GetCharacter() const;
302
303 // Gets the character generated by this key event ignoring concurrently-held
304 // modifiers (except shift).
305 uint16 GetUnmodifiedCharacter() const;
306
299 private: 307 private:
308 // A helper function to get the character generated by a key event in a
309 // platform independent way. It supports control characters as well.
310 // It assumes a US keyboard layout is used, so it may only be used when there
311 // is no native event or no better way to get the character.
312 // For example, if a virtual keyboard implementation can only generate key
313 // events with key_code and flags information, then there is no way for us to
314 // determine the actual character that should be generate by the key. Because
315 // a key_code only represents a physical key on the keyboard, it has nothing
316 // to do with the actual character printed on that key. In such case, the only
317 // thing we can do is to assume that we are using a US keyboard and get the
318 // character according to US keyboard layout definition.
319 // If a virtual keyboard implementation wants to support other keyboard
320 // layouts, that may generate different text for a certain key than on a US
321 // keyboard, a special native event object should be introduced to carry extra
322 // information to help determine the correct character.
323 // Take XKeyEvent as an example, it contains not only keycode and modifier
324 // flags but also group and other extra XKB information to help determine the
325 // correct character. That's why we can use XLookupString() function to get
326 // the correct text generated by a X key event (See how is GetCharacter()
327 // implemented in event_x.cc).
328 static uint16 GetCharacterFromKeyCode(ui::KeyboardCode key_code, int flags);
329
300 ui::KeyboardCode key_code_; 330 ui::KeyboardCode key_code_;
301 331
302 DISALLOW_COPY_AND_ASSIGN(KeyEvent); 332 DISALLOW_COPY_AND_ASSIGN(KeyEvent);
303 }; 333 };
304 334
305 //////////////////////////////////////////////////////////////////////////////// 335 ////////////////////////////////////////////////////////////////////////////////
306 // 336 //
307 // MouseWheelEvent class 337 // MouseWheelEvent class
308 // 338 //
309 // A MouseWheelEvent is used to propagate mouse wheel user events. 339 // A MouseWheelEvent is used to propagate mouse wheel user events.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 392
363 // Bitmask of supported ui::DragDropTypes::DragOperation by the source. 393 // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
364 int source_operations_; 394 int source_operations_;
365 395
366 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent); 396 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
367 }; 397 };
368 398
369 } // namespace views 399 } // namespace views
370 400
371 #endif // VIEWS_EVENTS_EVENT_H_ 401 #endif // VIEWS_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | views/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698