Chromium Code Reviews| 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 #ifndef PPAPI_CPP_INPUT_EVENT_H_ | 5 #ifndef PPAPI_CPP_INPUT_EVENT_H_ |
| 6 #define PPAPI_CPP_INPUT_EVENT_H_ | 6 #define PPAPI_CPP_INPUT_EVENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | |
| 9 | 10 |
| 10 #include "ppapi/c/ppb_input_event.h" | 11 #include "ppapi/c/ppb_input_event.h" |
| 11 #include "ppapi/cpp/resource.h" | 12 #include "ppapi/cpp/resource.h" |
| 12 | 13 |
| 13 /// @file | 14 /// @file |
| 14 /// This file defines the API used to handle mouse and keyboard input events. | 15 /// This file defines the API used to handle mouse and keyboard input events. |
| 15 | 16 |
| 16 namespace pp { | 17 namespace pp { |
| 17 | 18 |
| 18 class FloatPoint; | 19 class FloatPoint; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 uint32_t GetKeyCode() const; | 296 uint32_t GetKeyCode() const; |
| 296 | 297 |
| 297 /// Returns the typed character for the given character event. | 298 /// Returns the typed character for the given character event. |
| 298 /// | 299 /// |
| 299 /// @return A string var representing a single typed character for character | 300 /// @return A string var representing a single typed character for character |
| 300 /// input events. For non-character input events the return value will be an | 301 /// input events. For non-character input events the return value will be an |
| 301 /// undefined var. | 302 /// undefined var. |
| 302 Var GetCharacterText() const; | 303 Var GetCharacterText() const; |
| 303 }; | 304 }; |
| 304 | 305 |
| 306 class CompositionInputEvent : public InputEvent { | |
| 307 public: | |
| 308 /// Constructs an is_null() keyboard input event object. | |
|
yzshen1
2011/09/13 06:28:34
This is not a "keyboard" input event object.
kinaba
2011/09/13 09:29:01
Done.
| |
| 309 CompositionInputEvent(); | |
| 310 | |
| 311 /// Constructs a composition input event object from the provided generic | |
| 312 /// input event. If the given event is itself is_null() or is not a | |
| 313 /// composition input event, the composition object will be is_null(). | |
| 314 /// | |
| 315 /// @param[in] event A generic input event. | |
| 316 explicit CompositionInputEvent(const InputEvent& event); | |
| 317 | |
| 318 /// Returns the composition text as a UTF-8 string for the given composition | |
| 319 /// event. | |
| 320 /// | |
| 321 /// @return A string var representing the composition text. For non- | |
| 322 /// composition input events the return value will be an undefined var. | |
| 323 Var GetText() const; | |
| 324 | |
| 325 /// Returns the segmentation information by a list of indices of | |
| 326 /// a UTF-8 string returned by GetText. | |
| 327 /// | |
| 328 /// @return A vector representing segmentation information. For events other | |
| 329 /// than COMPOSITION_UPDATE, it returns an empty vector. | |
| 330 std::vector< std::pair<uint32_t, uint32_t> > GetSegments() const; | |
| 331 | |
| 332 /// Returns the index in the array retrieved by GetSegments indicating the | |
| 333 /// segment currently under composition. | |
| 334 /// | |
| 335 /// @return An integer indicating the index of the target segment. When there | |
| 336 /// is no active target segment, or the event is not COMPOSITION_UPDATE, | |
| 337 /// returns -1. | |
| 338 int32_t GetTargetSegment() const; | |
| 339 | |
| 340 /// Returns the selection (caret) position in the current composition text. | |
| 341 /// | |
| 342 /// @return A pair of integers indicating the selection range. | |
| 343 std::pair<uint32_t, uint32_t> GetSelection() const; | |
| 344 }; | |
| 345 | |
| 305 } // namespace pp | 346 } // namespace pp |
| 306 | 347 |
| 307 #endif // PPAPI_CPP_INPUT_EVENT_H_ | 348 #endif // PPAPI_CPP_INPUT_EVENT_H_ |
| OLD | NEW |