1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
7 * This file defines the Input Event interfaces.
17 * This enumeration contains the types of input events.
20 enum PP_InputEvent_Type
{
21 PP_INPUTEVENT_TYPE_UNDEFINED
= -1,
24 * Notification that a mouse button was pressed.
26 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
28 PP_INPUTEVENT_TYPE_MOUSEDOWN
= 0,
31 * Notification that a mouse button was released.
33 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
35 PP_INPUTEVENT_TYPE_MOUSEUP
= 1,
38 * Notification that a mouse button was moved when it is over the instance
39 * or dragged out of it.
41 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
43 PP_INPUTEVENT_TYPE_MOUSEMOVE
= 2,
46 * Notification that the mouse entered the instance's bounds.
48 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
50 PP_INPUTEVENT_TYPE_MOUSEENTER
= 3,
53 * Notification that a mouse left the instance's bounds.
55 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
57 PP_INPUTEVENT_TYPE_MOUSELEAVE
= 4,
60 * Notification that the scroll wheel was used.
62 * Register for this event using the PP_INPUTEVENT_CLASS_WHEEL class.
64 PP_INPUTEVENT_TYPE_WHEEL
= 5,
67 * Notification that a key transitioned from "up" to "down".
69 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
73 * TODO(brettw) differentiate from KEYDOWN.
75 PP_INPUTEVENT_TYPE_RAWKEYDOWN
= 6,
78 * Notification that a key was pressed. This does not necessarily correspond
79 * to a character depending on the key and language. Use the
80 * PP_INPUTEVENT_TYPE_CHAR for character input.
82 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
84 PP_INPUTEVENT_TYPE_KEYDOWN
= 7,
87 * Notification that a key was released.
89 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
91 PP_INPUTEVENT_TYPE_KEYUP
= 8,
94 * Notification that a character was typed. Use this for text input. Key
95 * down events may generate 0, 1, or more than one character event depending
96 * on the key, locale, and operating system.
98 * Register for this event using the PP_INPUTEVENT_CLASS_KEYBOARD class.
100 PP_INPUTEVENT_TYPE_CHAR
= 9,
103 * Notification that a context menu should be shown.
105 * This message will be sent when the user right-clicks or performs another
106 * OS-specific mouse command that should open a context menu. When this event
107 * is delivered depends on the system, on some systems (Mac) it will
108 * delivered after the mouse down event, and on others (Windows) it will be
109 * delivered after the mouse up event.
111 * You will always get the normal mouse events. For example, you may see
112 * MOUSEDOWN,CONTEXTMENU,MOUSEUP or MOUSEDOWN,MOUSEUP,CONTEXTMENU.
114 * The return value from the event handler determines if the context menu
115 * event will be passed to the page when you are using filtered input events
116 * (via RequestFilteringInputEvents()). In non-filtering mode the event will
117 * never be propagated and no context menu will be displayed. If you are
118 * handling mouse events in filtering mode, you may want to return true from
119 * this event even if you do not support a context menu to suppress the
122 * Register for this event using the PP_INPUTEVENT_CLASS_MOUSE class.
124 PP_INPUTEVENT_TYPE_CONTEXTMENU
= 10,
127 * Notification that an input method composition process has just started.
129 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
131 PP_INPUTEVENT_TYPE_IME_COMPOSITION_START
= 11,
134 * Notification that the input method composition string is updated.
136 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
138 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE
= 12,
141 * Notification that an input method composition process has completed.
143 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
145 PP_INPUTEVENT_TYPE_IME_COMPOSITION_END
= 13,
148 * Notification that an input method committed a string.
150 * Register for this event using the PP_INPUTEVENT_CLASS_IME class.
152 PP_INPUTEVENT_TYPE_IME_TEXT
= 14,
155 * Notification that a finger was placed on a touch-enabled device.
157 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
159 PP_INPUTEVENT_TYPE_TOUCHSTART
= 15,
162 * Notification that a finger was moved on a touch-enabled device.
164 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
166 PP_INPUTEVENT_TYPE_TOUCHMOVE
= 16,
169 * Notification that a finger was released on a touch-enabled device.
171 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
173 PP_INPUTEVENT_TYPE_TOUCHEND
= 17,
176 * Notification that a touch event was canceled.
178 * Register for this event using the PP_INPUTEVENT_CLASS_TOUCH class.
180 PP_INPUTEVENT_TYPE_TOUCHCANCEL
= 18
184 * This enumeration contains event modifier constants. Each modifier is one
185 * bit. Retrieve the modifiers from an input event using the GetEventModifiers
186 * function on PPB_InputEvent.
189 enum PP_InputEvent_Modifier
{
190 PP_INPUTEVENT_MODIFIER_SHIFTKEY
= 1 << 0,
191 PP_INPUTEVENT_MODIFIER_CONTROLKEY
= 1 << 1,
192 PP_INPUTEVENT_MODIFIER_ALTKEY
= 1 << 2,
193 PP_INPUTEVENT_MODIFIER_METAKEY
= 1 << 3,
194 PP_INPUTEVENT_MODIFIER_ISKEYPAD
= 1 << 4,
195 PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT
= 1 << 5,
196 PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN
= 1 << 6,
197 PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN
= 1 << 7,
198 PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN
= 1 << 8,
199 PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY
= 1 << 9,
200 PP_INPUTEVENT_MODIFIER_NUMLOCKKEY
= 1 << 10,
201 PP_INPUTEVENT_MODIFIER_ISLEFT
= 1 << 11,
202 PP_INPUTEVENT_MODIFIER_ISRIGHT
= 1 << 12
206 * This enumeration contains constants representing each mouse button. To get
207 * the mouse button for a mouse down or up event, use GetMouseButton on
211 enum PP_InputEvent_MouseButton
{
212 PP_INPUTEVENT_MOUSEBUTTON_NONE
= -1,
213 PP_INPUTEVENT_MOUSEBUTTON_LEFT
= 0,
214 PP_INPUTEVENT_MOUSEBUTTON_MIDDLE
= 1,
215 PP_INPUTEVENT_MOUSEBUTTON_RIGHT
= 2
219 enum PP_InputEvent_Class
{
221 * Request mouse input events.
223 * Normally you will request mouse events by calling RequestInputEvents().
224 * The only use case for filtered events (via RequestFilteringInputEvents())
225 * is for instances that have irregular outlines and you want to perform hit
226 * testing, which is very uncommon. Requesting non-filtered mouse events will
227 * lead to higher performance.
229 PP_INPUTEVENT_CLASS_MOUSE
= 1 << 0,
232 * Requests keyboard events. Often you will want to request filtered mode
233 * (via RequestFilteringInputEvents) for keyboard events so you can pass on
234 * events (by returning false) that you don't handle. For example, if you
235 * don't request filtered mode and the user pressed "Page Down" when your
236 * instance has focus, the page won't scroll which will be a poor experience.
238 * A small number of tab and window management commands like Alt-F4 are never
239 * sent to the page. You can not request these keyboard commands since it
240 * would allow pages to trap users on a page.
242 PP_INPUTEVENT_CLASS_KEYBOARD
= 1 << 1,
245 * Identifies scroll wheel input event. Wheel events must be requested in
246 * filtering mode via RequestFilteringInputEvents(). This is because many
247 * wheel commands should be forwarded to the page.
249 * Most instances will not need this event. Consuming wheel events by
250 * returning true from your filtered event handler will prevent the user from
251 * scrolling the page when the mouse is over the instance which can be very
254 * If you handle wheel events (for example, you have a document viewer which
255 * the user can scroll), the recommended behavior is to return false only if
256 * the wheel event actually causes your document to scroll. When the user
257 * reaches the end of the document, return false to indicating that the event
258 * was not handled. This will then forward the event to the containing page
259 * for scrolling, producing the nested scrolling behavior users expect from
262 PP_INPUTEVENT_CLASS_WHEEL
= 1 << 2,
265 * Identifies touch input events.
267 * Request touch events only if you intend to handle them. If the browser
268 * knows you do not need to handle touch events, it can handle them at a
269 * higher level and achieve higher performance. If the plugin does not
270 * register for touch-events, then it will receive synthetic mouse events that
271 * are generated from the touch events (e.g. mouse-down for touch-start,
272 * mouse-move for touch-move (with left-button down), and mouse-up for
273 * touch-end. If the plugin does register for touch events, then the synthetic
274 * mouse events are not created.
276 PP_INPUTEVENT_CLASS_TOUCH
= 1 << 3,
279 * Identifies IME composition input events.
281 * Request this input event class if you allow on-the-spot IME input.
283 PP_INPUTEVENT_CLASS_IME
= 1 << 4
287 * The <code>PPB_InputEvent</code> interface contains pointers to several
288 * functions related to generic input events on the browser.
290 [version=1.0, macro
="PPB_INPUT_EVENT_INTERFACE"]
291 interface PPB_InputEvent
{
293 * RequestInputEvent() requests that input events corresponding to the given
294 * input events are delivered to the instance.
296 * It's recommended that you use RequestFilteringInputEvents() for keyboard
297 * events instead of this function so that you don't interfere with normal
298 * browser accelerators.
300 * By default, no input events are delivered. Call this function with the
301 * classes of events you are interested in to have them be delivered to
302 * the instance. Calling this function will override any previous setting for
303 * each specified class of input events (for example, if you previously
304 * called RequestFilteringInputEvents(), this function will set those events
305 * to non-filtering mode).
307 * Input events may have high overhead, so you should only request input
308 * events that your plugin will actually handle. For example, the browser may
309 * do optimizations for scroll or touch events that can be processed
310 * substantially faster if it knows there are no non-default receivers for
311 * that message. Requesting that such messages be delivered, even if they are
312 * processed very quickly, may have a noticeable effect on the performance of
315 * Note that synthetic mouse events will be generated from touch events if
316 * (and only if) you do not request touch events.
318 * When requesting input events through this function, the events will be
319 * delivered and <i>not</i> bubbled to the page. This means that even if you
320 * aren't interested in the message, no other parts of the page will get
321 * a crack at the message.
323 * <strong>Example:</strong>
325 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
326 * RequestFilteringInputEvents(instance,
327 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
330 * @param instance The <code>PP_Instance</code> of the instance requesting
333 * @param event_classes A combination of flags from
334 * <code>PP_InputEvent_Class</code> that identifies the classes of events the
335 * instance is requesting. The flags are combined by logically ORing their
338 * @return <code>PP_OK</code> if the operation succeeded,
339 * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
340 * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
341 * illegal. In the case of an invalid bit, all valid bits will be applied
342 * and only the illegal bits will be ignored. The most common cause of a
343 * <code>PP_ERROR_NOTSUPPORTED</code> return value is requesting keyboard
344 * events, these must use RequestFilteringInputEvents().
346 int32_t RequestInputEvents
([in] PP_Instance instance
,
347 [in] uint32_t event_classes
);
350 * RequestFilteringInputEvents() requests that input events corresponding to
351 * the given input events are delivered to the instance for filtering.
353 * By default, no input events are delivered. In most cases you would
354 * register to receive events by calling RequestInputEvents(). In some cases,
355 * however, you may wish to filter events such that they can be bubbled up
356 * to the DOM. In this case, register for those classes of events using
357 * this function instead of RequestInputEvents().
359 * Filtering input events requires significantly more overhead than just
360 * delivering them to the instance. As such, you should only request
361 * filtering in those cases where it's absolutely necessary. The reason is
362 * that it requires the browser to stop and block for the instance to handle
363 * the input event, rather than sending the input event asynchronously. This
364 * can have significant overhead.
366 * <strong>Example:</strong>
368 * RequestInputEvents(instance, PP_INPUTEVENT_CLASS_MOUSE);
369 * RequestFilteringInputEvents(instance,
370 * PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
373 * @return <code>PP_OK</code> if the operation succeeded,
374 * <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
375 * <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
376 * illegal. In the case of an invalid bit, all valid bits will be applied
377 * and only the illegal bits will be ignored.
379 int32_t RequestFilteringInputEvents
([in] PP_Instance instance
,
380 [in] uint32_t event_classes
);
383 * ClearInputEventRequest() requests that input events corresponding to the
384 * given input classes no longer be delivered to the instance.
386 * By default, no input events are delivered. If you have previously
387 * requested input events via RequestInputEvents() or
388 * RequestFilteringInputEvents(), this function will unregister handling
389 * for the given instance. This will allow greater browser performance for
392 * Note that you may still get some input events after clearing the flag if
393 * they were dispatched before the request was cleared. For example, if
394 * there are 3 mouse move events waiting to be delivered, and you clear the
395 * mouse event class during the processing of the first one, you'll still
396 * receive the next two. You just won't get more events generated.
398 * @param instance The <code>PP_Instance</code> of the instance requesting
399 * to no longer receive the given events.
401 * @param event_classes A combination of flags from
402 * <code>PP_InputEvent_Class</code> that identify the classes of events the
403 * instance is no longer interested in.
405 void ClearInputEventRequest
([in] PP_Instance instance
,
406 [in] uint32_t event_classes
);
409 * IsInputEvent() returns true if the given resource is a valid input event
412 * @param[in] resource A <code>PP_Resource</code> corresponding to a generic
415 * @return <code>PP_TRUE</code> if the given resource is a valid input event
418 PP_Bool IsInputEvent
([in] PP_Resource resource
);
421 * GetType() returns the type of input event for the given input event
424 * @param[in] resource A <code>PP_Resource</code> corresponding to an input
427 * @return A <code>PP_InputEvent_Type</code> if its a valid input event or
428 * <code>PP_INPUTEVENT_TYPE_UNDEFINED</code> if the resource is invalid.
430 PP_InputEvent_Type GetType
([in] PP_Resource event
);
433 * GetTimeStamp() Returns the time that the event was generated. This will be
434 * before the current time since processing and dispatching the event has
435 * some overhead. Use this value to compare the times the user generated two
436 * events without being sensitive to variable processing time.
438 * @param[in] resource A <code>PP_Resource</code> corresponding to the event.
440 * @return The return value is in time ticks, which is a monotonically
441 * increasing clock not related to the wall clock time. It will not change
442 * if the user changes their clock or daylight savings time starts, so can
443 * be reliably used to compare events. This means, however, that you can't
444 * correlate event times to a particular time of day on the system clock.
446 PP_TimeTicks GetTimeStamp
([in] PP_Resource event
);
449 * GetModifiers() returns a bitfield indicating which modifiers were down
450 * at the time of the event. This is a combination of the flags in the
451 * <code>PP_InputEvent_Modifier</code> enum.
453 * @param[in] resource A <code>PP_Resource</code> corresponding to an input
456 * @return The modifiers associated with the event, or 0 if the given
457 * resource is not a valid event resource.
459 uint32_t GetModifiers
([in] PP_Resource event
);
463 * The <code>PPB_MouseInputEvent</code> interface contains pointers to several
464 * functions related to mouse input events.
466 [macro
="PPB_MOUSE_INPUT_EVENT_INTERFACE"]
467 interface PPB_MouseInputEvent
{
469 * Create() creates a mouse input event with the given parameters. Normally
470 * you will get a mouse event passed through the
471 * <code>HandleInputEvent</code> and will not need to create them, but some
472 * applications may want to create their own for internal use. The type must
473 * be one of the mouse event types.
475 * @param[in] instance The instance for which this event occurred.
477 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
480 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
481 * when the event occurred.
483 * @param[in] modifiers A bit field combination of the
484 * <code>PP_InputEvent_Modifier</code> flags.
486 * @param[in] mouse_button The button that changed for mouse down or up
487 * events. This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for
488 * mouse move, enter, and leave events.
490 * @param[in] mouse_position A <code>Point</code> containing the x and y
491 * position of the mouse when the event occurred.
493 * @return A <code>PP_Resource</code> containing the new mouse input event.
495 PP_Resource Create
([in] PP_Instance instance
,
496 [in] PP_InputEvent_Type type
,
497 [in] PP_TimeTicks time_stamp
,
498 [in] uint32_t modifiers
,
499 [in] PP_InputEvent_MouseButton mouse_button
,
500 [in] PP_Point mouse_position
,
501 [in] int32_t click_count
);
504 * Create() creates a mouse input event with the given parameters. Normally
505 * you will get a mouse event passed through the
506 * <code>HandleInputEvent</code> and will not need to create them, but some
507 * applications may want to create their own for internal use. The type must
508 * be one of the mouse event types.
510 * @param[in] instance The instance for which this event occurred.
512 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
515 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
516 * when the event occurred.
518 * @param[in] modifiers A bit field combination of the
519 * <code>PP_InputEvent_Modifier</code> flags.
521 * @param[in] mouse_button The button that changed for mouse down or up
522 * events. This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for
523 * mouse move, enter, and leave events.
525 * @param[in] mouse_position A <code>Point</code> containing the x and y
526 * position of the mouse when the event occurred.
528 * @param[in] mouse_movement The change in position of the mouse.
530 * @return A <code>PP_Resource</code> containing the new mouse input event.
533 PP_Resource Create
([in] PP_Instance instance
,
534 [in] PP_InputEvent_Type type
,
535 [in] PP_TimeTicks time_stamp
,
536 [in] uint32_t modifiers
,
537 [in] PP_InputEvent_MouseButton mouse_button
,
538 [in] PP_Point mouse_position
,
539 [in] int32_t click_count
,
540 [in] PP_Point mouse_movement
);
542 * IsMouseInputEvent() determines if a resource is a mouse event.
544 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
546 * @return <code>PP_TRUE</code> if the given resource is a valid mouse input
547 * event, otherwise <code>PP_FALSE</code>.
549 PP_Bool IsMouseInputEvent
([in] PP_Resource resource
);
552 * GetButton() returns the mouse button that generated a mouse down or up
555 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
558 * @return The mouse button associated with mouse down and up events. This
559 * value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for mouse move,
560 * enter, and leave events, and for all non-mouse events.
562 PP_InputEvent_MouseButton GetButton
([in] PP_Resource mouse_event
);
565 * GetPosition() returns the pixel location of a mouse input event. When
566 * the mouse is locked, it returns the last known mouse position just as
567 * mouse lock was entered.
569 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
572 * @return The point associated with the mouse event, relative to the upper-
573 * left of the instance receiving the event. These values can be negative for
574 * mouse drags. The return value will be (0, 0) for non-mouse events.
576 [returnByValue
] PP_Point GetPosition
([in] PP_Resource mouse_event
);
579 * TODO(brettw) figure out exactly what this means.
581 int32_t GetClickCount
([in] PP_Resource mouse_event
);
584 * Returns the change in position of the mouse. When the mouse is locked,
585 * although the mouse position doesn't actually change, this function
586 * still provides movement information, which indicates what the change in
587 * position would be had the mouse not been locked.
589 * @param[in] mouse_event A <code>PP_Resource</code> corresponding to a
592 * @return The change in position of the mouse, relative to the previous
596 PP_Point GetMovement
([in] PP_Resource mouse_event
);
601 * The <code>PPB_WheelIputEvent</code> interface contains pointers to several
602 * functions related to wheel input events.
604 [version=1.0, macro
="PPB_WHEEL_INPUT_EVENT_INTERFACE"]
605 interface PPB_WheelInputEvent
{
607 * Create() creates a wheel input event with the given parameters. Normally
608 * you will get a wheel event passed through the
609 * <code>HandleInputEvent</code> and will not need to create them, but some
610 * applications may want to create their own for internal use.
612 * @param[in] instance The instance for which this event occurred.
614 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
615 * when the event occurred.
617 * @param[in] modifiers A bit field combination of the
618 * <code>PP_InputEvent_Modifier</code> flags.
620 * @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll
623 * @param[in] wheel_ticks The number of "clicks" of the scroll wheel that
624 * have produced the event.
626 * @param[in] scroll_by_page When true, the user is requesting to scroll
627 * by pages. When false, the user is requesting to scroll by lines.
629 * @return A <code>PP_Resource</code> containing the new wheel input event.
631 PP_Resource Create
([in] PP_Instance instance
,
632 [in] PP_TimeTicks time_stamp
,
633 [in] uint32_t modifiers
,
634 [in] PP_FloatPoint wheel_delta
,
635 [in] PP_FloatPoint wheel_ticks
,
636 [in] PP_Bool scroll_by_page
);
639 * IsWheelInputEvent() determines if a resource is a wheel event.
641 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to an
644 * @return <code>PP_TRUE</code> if the given resource is a valid wheel input
647 PP_Bool IsWheelInputEvent
([in] PP_Resource resource
);
650 * GetDelta() returns the amount vertically and horizontally the user has
651 * requested to scroll by with their mouse wheel. A scroll down or to the
652 * right (where the content moves up or left) is represented as positive
653 * values, and a scroll up or to the left (where the content moves down or
654 * right) is represented as negative values.
656 * This amount is system dependent and will take into account the user's
657 * preferred scroll sensitivity and potentially also nonlinear acceleration
658 * based on the speed of the scrolling.
660 * Devices will be of varying resolution. Some mice with large detents will
661 * only generate integer scroll amounts. But fractional values are also
662 * possible, for example, on some trackpads and newer mice that don't have
665 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
668 * @return The vertical and horizontal scroll values. The units are either in
669 * pixels (when scroll_by_page is false) or pages (when scroll_by_page is
670 * true). For example, y = -3 means scroll up 3 pixels when scroll_by_page
671 * is false, and scroll up 3 pages when scroll_by_page is true.
673 PP_FloatPoint GetDelta
([in] PP_Resource wheel_event
);
676 * GetTicks() returns the number of "clicks" of the scroll wheel
677 * that have produced the event. The value may have system-specific
678 * acceleration applied to it, depending on the device. The positive and
679 * negative meanings are the same as for GetDelta().
681 * If you are scrolling, you probably want to use the delta values. These
682 * tick events can be useful if you aren't doing actual scrolling and don't
683 * want or pixel values. An example may be cycling between different items in
686 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
689 * @return The number of "clicks" of the scroll wheel. You may receive
690 * fractional values for the wheel ticks if the mouse wheel is high
691 * resolution or doesn't have "clicks". If your program wants discrete
692 * events (as in the "picking items" example) you should accumulate
693 * fractional click values from multiple messages until the total value
694 * reaches positive or negative one. This should represent a similar amount
695 * of scrolling as for a mouse that has a discrete mouse wheel.
697 PP_FloatPoint GetTicks
([in] PP_Resource wheel_event
);
700 * GetScrollByPage() indicates if the scroll delta x/y indicates pages or
701 * lines to scroll by.
703 * @param[in] wheel_event A <code>PP_Resource</code> corresponding to a wheel
706 * @return <code>PP_TRUE</code> if the event is a wheel event and the user is
707 * scrolling by pages. <code>PP_FALSE</code> if not or if the resource is not
710 PP_Bool GetScrollByPage
([in] PP_Resource wheel_event
);
714 * The <code>PPB_KeyboardInputEvent</code> interface contains pointers to
715 * several functions related to keyboard input events.
717 [version=1.0, macro
="PPB_KEYBOARD_INPUT_EVENT_INTERFACE"]
718 interface PPB_KeyboardInputEvent
{
720 * Creates a keyboard input event with the given parameters. Normally you
721 * will get a keyboard event passed through the HandleInputEvent and will not
722 * need to create them, but some applications may want to create their own
723 * for internal use. The type must be one of the keyboard event types.
725 * @param[in] instance The instance for which this event occurred.
727 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
730 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
731 * when the event occurred.
733 * @param[in] modifiers A bit field combination of the
734 * <code>PP_InputEvent_Modifier</code> flags.
736 * @param[in] key_code This value reflects the DOM KeyboardEvent
737 * <code>keyCode</code> field, which is the Windows-style Virtual Key
740 * @param[in] character_text This value represents the typed character as a
743 * @return A <code>PP_Resource</code> containing the new keyboard input
747 PP_Resource Create
([in] PP_Instance instance
,
748 [in] PP_InputEvent_Type type
,
749 [in] PP_TimeTicks time_stamp
,
750 [in] uint32_t modifiers
,
751 [in] uint32_t key_code
,
752 [in] PP_Var character_text
);
755 * Creates a keyboard input event with the given parameters. Normally you
756 * will get a keyboard event passed through the HandleInputEvent and will not
757 * need to create them, but some applications may want to create their own
758 * for internal use. The type must be one of the keyboard event types.
760 * @param[in] instance The instance for which this event occurred.
762 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
765 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
766 * when the event occurred.
768 * @param[in] modifiers A bit field combination of the
769 * <code>PP_InputEvent_Modifier</code> flags.
771 * @param[in] key_code This value reflects the DOM KeyboardEvent
772 * <code>keyCode</code> field, which is the Windows-style Virtual Key
775 * @param[in] character_text This value represents the typed character as a
778 * @param[in] code This value represents the DOM3 |code| string that
779 * corresponds to the physical key being pressed.
781 * @return A <code>PP_Resource</code> containing the new keyboard input
785 PP_Resource Create
([in] PP_Instance instance
,
786 [in] PP_InputEvent_Type type
,
787 [in] PP_TimeTicks time_stamp
,
788 [in] uint32_t modifiers
,
789 [in] uint32_t key_code
,
790 [in] PP_Var character_text
,
794 * IsKeyboardInputEvent() determines if a resource is a keyboard event.
796 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
798 * @return <code>PP_TRUE</code> if the given resource is a valid input event.
800 PP_Bool IsKeyboardInputEvent
([in] PP_Resource resource
);
803 * GetKeyCode() returns the DOM keyCode field for the keyboard event.
804 * Chrome populates this with the Windows-style Virtual Key code of the key.
806 * @param[in] key_event A <code>PP_Resource</code> corresponding to a
809 * @return The DOM keyCode field for the keyboard event.
811 uint32_t GetKeyCode
([in] PP_Resource key_event
);
814 * GetCharacterText() returns the typed character as a UTF-8 string for the
815 * given character event.
817 * @param[in] character_event A <code>PP_Resource</code> corresponding to a
820 * @return A string var representing a single typed character for character
821 * input events. For non-character input events the return value will be an
824 PP_Var GetCharacterText
([in] PP_Resource character_event
);
827 * GetCode() returns the DOM |code| field for this keyboard event, as
828 * defined in the DOM3 Events spec:
829 * http://www.w3.org/TR/DOM-Level-3-Events/
831 * @param[in] key_event The key event for which to return the key code.
833 * @return The string that contains the DOM |code| for the keyboard event.
836 PP_Var GetCode
([in] PP_Resource key_event
);
840 enum PP_TouchListType
{
842 * The list of all TouchPoints which are currently down.
844 PP_TOUCHLIST_TYPE_TOUCHES
= 0,
847 * The list of all TouchPoints whose state has changed since the last
850 PP_TOUCHLIST_TYPE_CHANGEDTOUCHES
= 1,
853 * The list of all TouchPoints which are targeting this plugin. This is a
856 PP_TOUCHLIST_TYPE_TARGETTOUCHES
= 2
860 * The <code>PPB_TouchInputEvent</code> interface contains pointers to several
861 * functions related to touch events.
863 [version=1.0, macro
="PPB_TOUCH_INPUT_EVENT_INTERFACE"]
864 interface PPB_TouchInputEvent
{
866 * Creates a touch input event with the given parameters. Normally you
867 * will get a touch event passed through the HandleInputEvent and will not
868 * need to create them, but some applications may want to create their own
869 * for internal use. The type must be one of the touch event types.
870 * This newly created touch input event does not have any touch point in any
871 * of the touch-point lists. <code>AddTouchPoint</code> should be called to
872 * add the touch-points.
874 * @param[in] instance The instance for which this event occurred.
876 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
879 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
880 * when the event occurred.
882 * @param[in] modifiers A bit field combination of the
883 * <code>PP_InputEvent_Modifier</code> flags.
885 * @return A <code>PP_Resource</code> containing the new touch input event.
887 PP_Resource Create
([in] PP_Instance instance
,
888 [in] PP_InputEvent_Type type
,
889 [in] PP_TimeTicks time_stamp
,
890 [in] uint32_t modifiers
);
893 * Adds a touch point to the touch event in the specified touch-list.
895 * @param[in] touch_event A <code>PP_Resource</code> corresponding to a touch
898 * @param[in] list The list to add the touch point to.
900 * @param[in] point The point to add to the list.
902 void AddTouchPoint
([in] PP_Resource touch_event
,
903 [in] PP_TouchListType list
,
904 [in] PP_TouchPoint point
);
907 * IsTouchInputEvent() determines if a resource is a touch event.
909 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
911 * @return <code>PP_TRUE</code> if the given resource is a valid touch input
912 * event, otherwise <code>PP_FALSE</code>.
914 PP_Bool IsTouchInputEvent
([in] PP_Resource resource
);
917 * Returns the number of touch-points in the specified list.
919 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
922 * @param[in] list The list.
924 * @return The number of touch-points in the specified list.
926 uint32_t GetTouchCount
([in] PP_Resource resource
,
927 [in] PP_TouchListType list
);
930 * Returns the touch-point at the specified index from the specified list.
932 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
935 * @param[in] list The list.
937 * @param[in] index The index.
939 * @return A <code>PP_TouchPoint</code> representing the touch-point.
941 PP_TouchPoint GetTouchByIndex
([in] PP_Resource resource
,
942 [in] PP_TouchListType list
,
943 [in] uint32_t index
);
946 * Returns the touch-point with the specified touch-id in the specified list.
948 * @param[in] resource A <code>PP_Resource</code> corresponding to a touch
951 * @param[in] list The list.
953 * @param[in] touch_id The id of the touch-point.
955 * @return A <code>PP_TouchPoint</code> representing the touch-point.
957 PP_TouchPoint GetTouchById
([in] PP_Resource resource
,
958 [in] PP_TouchListType list
,
959 [in] uint32_t touch_id
);
962 [macro
="PPB_IME_INPUT_EVENT_INTERFACE"]
963 interface PPB_IMEInputEvent
{
965 * Create() creates an IME input event with the given parameters. Normally
966 * you will get an IME event passed through the <code>HandleInputEvent</code>
967 * and will not need to create them, but some applications may want to create
968 * their own for internal use.
970 * @param[in] instance The instance for which this event occurred.
972 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
973 * input event. The type must be one of the IME event types.
975 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
976 * when the event occurred.
978 * @param[in] text The string returned by <code>GetText</code>.
980 * @param[in] segment_number The number returned by
981 * <code>GetSegmentNumber</code>.
983 * @param[in] segment_offsets The array of numbers returned by
984 * <code>GetSegmentOffset</code>. If <code>segment_number</code> is zero,
985 * the number of elements of the array should be zero. If
986 * <code>segment_number</code> is non-zero, the length of the array must be
987 * <code>segment_number</code> + 1.
989 * @param[in] target_segment The number returned by
990 * <code>GetTargetSegment</code>.
992 * @param[in] selection_start The start index returned by
993 * <code>GetSelection</code>.
995 * @param[in] selection_end The end index returned by
996 * <code>GetSelection</code>.
998 * @return A <code>PP_Resource</code> containing the new IME input event.
1000 PP_Resource Create
([in] PP_Instance instance
,
1001 [in] PP_InputEvent_Type type
,
1002 [in] PP_TimeTicks time_stamp
,
1004 [in] uint32_t segment_number
,
1005 [in] uint32_t
[] segment_offsets
,
1006 [in] int32_t target_segment
,
1007 [in] uint32_t selection_start
,
1008 [in] uint32_t selection_end
);
1011 * IsIMEInputEvent() determines if a resource is an IME event.
1013 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
1015 * @return <code>PP_TRUE</code> if the given resource is a valid input event.
1017 PP_Bool IsIMEInputEvent
([in] PP_Resource resource
);
1020 * GetText() returns the composition text as a UTF-8 string for the given IME
1023 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1026 * @return A string var representing the composition text. For non-IME input
1027 * events the return value will be an undefined var.
1029 PP_Var GetText
([in] PP_Resource ime_event
);
1032 * GetSegmentNumber() returns the number of segments in the composition text.
1034 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1037 * @return The number of segments. For events other than COMPOSITION_UPDATE,
1040 uint32_t GetSegmentNumber
([in] PP_Resource ime_event
);
1043 * GetSegmentOffset() returns the position of the index-th segmentation point
1044 * in the composition text. The position is given by a byte-offset (not a
1045 * character-offset) of the string returned by GetText(). It always satisfies
1046 * 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1)
1047 * < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()).
1048 * Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the range
1049 * of the i-th segment, and hence GetSegmentNumber() can be a valid argument
1050 * to this function instead of an off-by-1 error.
1052 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1055 * @param[in] index An integer indicating a segment.
1057 * @return The byte-offset of the segmentation point. If the event is not
1058 * COMPOSITION_UPDATE or index is out of range, returns 0.
1060 uint32_t GetSegmentOffset
([in] PP_Resource ime_event
,
1061 [in] uint32_t index
);
1064 * GetTargetSegment() returns the index of the current target segment of
1067 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1070 * @return An integer indicating the index of the target segment. When there
1071 * is no active target segment, or the event is not COMPOSITION_UPDATE,
1074 int32_t GetTargetSegment
([in] PP_Resource ime_event
);
1077 * GetSelection() returns the range selected by caret in the composition text.
1079 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
1082 * @param[out] start The start position of the current selection.
1084 * @param[out] end The end position of the current selection.
1086 void GetSelection
([in] PP_Resource ime_event
,
1087 [out] uint32_t start
,
1088 [out] uint32_t end
);