| OLD | NEW |
| 1 {{+bindTo:partials.standard_nacl_api}} | 1 {{+bindTo:partials.standard_nacl_article}} |
| 2 | 2 |
| 3 <section id="view-change-focus-and-input-events"> | 3 <section id="view-change-focus-and-input-events"> |
| 4 <h1 id="view-change-focus-and-input-events">View Change, Focus, and Input Events
</h1> | 4 <span id="view-focus-input-events"></span><h1 id="view-change-focus-and-input-ev
ents"><span id="view-focus-input-events"></span>View Change, Focus, and Input Ev
ents</h1> |
| 5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
| 6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
| 7 <li><a class="reference internal" href="#overview" id="id2">Overview</a></li> | 7 <li><a class="reference internal" href="#overview" id="id2">Overview</a></li> |
| 8 <li><p class="first"><a class="reference internal" href="#handling-browser-event
s" id="id3">Handling browser events</a></p> | 8 <li><p class="first"><a class="reference internal" href="#handling-browser-event
s" id="id3">Handling browser events</a></p> |
| 9 <ul class="small-gap"> | 9 <ul class="small-gap"> |
| 10 <li><a class="reference internal" href="#didchangeview" id="id4">DidChangeView()
</a></li> | 10 <li><a class="reference internal" href="#didchangeview" id="id4">DidChangeView()
</a></li> |
| 11 <li><a class="reference internal" href="#didchangefocus" id="id5">DidChangeFocus
()</a></li> | 11 <li><a class="reference internal" href="#didchangefocus" id="id5">DidChangeFocus
()</a></li> |
| 12 </ul> | 12 </ul> |
| 13 </li> | 13 </li> |
| 14 <li><p class="first"><a class="reference internal" href="#handling-input-events"
id="id6">Handling input events</a></p> | 14 <li><p class="first"><a class="reference internal" href="#handling-input-events"
id="id6">Handling input events</a></p> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 43 inside the rectangle managed by a module) also generates input events, which | 43 inside the rectangle managed by a module) also generates input events, which |
| 44 are passed to the module. The browser also passes view change and focus events | 44 are passed to the module. The browser also passes view change and focus events |
| 45 that affect a module’s instance to the module. Native Client modules can | 45 that affect a module’s instance to the module. Native Client modules can |
| 46 override certain functions in the <a class="reference external" href="/native-cl
ient/pepper_stable/cpp/classpp_1_1_instance">pp::Instance</a> class to handle in
put | 46 override certain functions in the <a class="reference external" href="/native-cl
ient/pepper_stable/cpp/classpp_1_1_instance">pp::Instance</a> class to handle in
put |
| 47 and browser events. These functions are listed in the table below:</p> | 47 and browser events. These functions are listed in the table below:</p> |
| 48 <table border="1" class="docutils"> | 48 <table border="1" class="docutils"> |
| 49 <colgroup> | 49 <colgroup> |
| 50 </colgroup> | 50 </colgroup> |
| 51 <thead valign="bottom"> | 51 <thead valign="bottom"> |
| 52 <tr class="row-odd"><th class="head">Function</th> | 52 <tr class="row-odd"><th class="head">Function</th> |
| 53 <th class="head">Event</th> | |
| 54 <th class="head">Use</th> | 53 <th class="head">Use</th> |
| 55 </tr> | 54 </tr> |
| 56 </thead> | 55 </thead> |
| 57 <tbody valign="top"> | 56 <tbody valign="top"> |
| 58 <tr class="row-even"><td><code>DidChangeView</code></td> | 57 <tr class="row-even"><td><dl class="first last docutils"> |
| 59 <td>Called when the position, | 58 <dt><code>DidChangeView</code></dt> |
| 60 size, or clip rectangle | 59 <dd>Called when the position, size, or |
| 61 of the module’s instance in | 60 clip rectangle of the module’s |
| 62 the browser has changed. | 61 instance in the browser has |
| 63 This event also occurs | 62 changed. This event also occurs |
| 64 when browser window is | 63 when the browser window is resized |
| 65 resized or mouse wheel | 64 or the mouse wheel is scrolled.</dd> |
| 66 is scrolled.</td> | 65 </dl> |
| 67 <td>An implementation | 66 </td> |
| 68 of this function | 67 <td>An implementation of this function might |
| 69 might check the size | 68 check the size of the module instance’s |
| 70 of the module | 69 rectangle has changed and reallocate the |
| 71 instance’s rectangle | 70 graphcs context when a different size is |
| 72 has changed and | 71 received.</td> |
| 73 reallocate the | |
| 74 graphics context | |
| 75 when a different | |
| 76 size is received.</td> | |
| 77 </tr> | 72 </tr> |
| 78 <tr class="row-odd"><td><code>DidChangeFocus</code></td> | 73 <tr class="row-odd"><td><dl class="first last docutils"> |
| 79 <td>Called when the module’s | 74 <dt><code>DidChangeFocus</code></dt> |
| 80 instance in the browser | 75 <dd>Called when the module’s instance |
| 81 has gone in or out of | 76 in the browser has gone in or out |
| 82 focus (usually by | 77 of focus (usually by clicking |
| 83 clicking inside or | 78 inside or outside the module |
| 84 outside the module | 79 instance). Having focus means that |
| 85 instance). Having focus | 80 keyboard events will be sent to the |
| 86 means that keyboard | 81 module instance. An instance’s |
| 87 events will be sent to | 82 default condition is that it does |
| 88 the module instance. | 83 not have focus.</dd> |
| 89 An instance’s default | 84 </dl> |
| 90 condition is that it | 85 </td> |
| 91 does not have focus.</td> | 86 <td>An implementation of this function might |
| 92 <td>An implementation | 87 start or stop an animation or a blinking |
| 93 of this function | 88 cursor.</td> |
| 94 might start or stop | |
| 95 an animation or a | |
| 96 blinking cursor.</td> | |
| 97 </tr> | 89 </tr> |
| 98 <tr class="row-even"><td><code>HandleDocumentLoad</code></td> | 90 <tr class="row-even"><td><dl class="first last docutils"> |
| 99 <td>Called after | 91 <dt><code>HandleDocumentLoad</code></dt> |
| 100 <code>pp::Instance::Init()</code> | 92 <dd><code>pp::Instance::Init()</code> for a |
| 101 for a full-frame module | 93 full-frame module instance that was |
| 102 instance that was | 94 instantiated based on the MIME |
| 103 instantiated based on | 95 type of a DOMWindow navigation. |
| 104 the MIME type of a | 96 This situation only applies to |
| 105 DOMWindow navigation. | 97 modules that are pre-registered to |
| 106 This situation only | 98 handle certain MIME types. If you |
| 107 applies to modules that | 99 haven’t specifically registered to |
| 108 are pre-registered to | 100 handle a MIME type or aren’t |
| 109 handle certain MIME | 101 positive this applies to you, your |
| 110 types. If you haven’t | 102 implementation of this function can |
| 111 specifically registered | 103 just return false.</dd> |
| 112 to handle a MIME type or | 104 </dl> |
| 113 aren’t positive this | 105 </td> |
| 114 applies to you, your | 106 <td>This API is only applicable when you are |
| 115 implementation of this | 107 writing an extension to enhance the |
| 116 function can just return | 108 abilities of the Chrome web browser. For |
| 117 false.</td> | 109 example, a PDF viewer might implement |
| 118 <td>This API is only | 110 this function to download and display a |
| 119 applicable when you | 111 PDF file.</td> |
| 120 are writing an | |
| 121 extension to enhance | |
| 122 the abilities of | |
| 123 the Chrome web | |
| 124 browser. For | |
| 125 example, a PDF | |
| 126 viewer might | |
| 127 implement this | |
| 128 function to download | |
| 129 and display a PDF | |
| 130 file.</td> | |
| 131 </tr> | 112 </tr> |
| 132 <tr class="row-odd"><td><code>HandleInputEvent</code></td> | 113 <tr class="row-odd"><td><dl class="first last docutils"> |
| 133 <td>Called when a user | 114 <dt><code>HandleInputEvent</code></dt> |
| 134 interacts with the | 115 <dd>Called when a user interacts with |
| 135 module’s instance in the | 116 the module’s instance in the |
| 136 browser using an input | 117 browser using an input device such |
| 137 device such as a mouse | 118 as a mouse or keyboard. You must |
| 138 or keyboard. You must | 119 register your module to accept |
| 139 register your module to | 120 input events using |
| 140 accept input events | |
| 141 using | |
| 142 <code>RequestInputEvents()</code> | 121 <code>RequestInputEvents()</code> |
| 143 for mouse events and | 122 for mouse events and |
| 144 <code>RequestFilteringInputEvents</code> | 123 <code>RequestFilteringInputEvents()</code> |
| 145 for keyboard events | 124 for keyboard events prior to |
| 146 prior to overriding this | 125 overriding this function.</dd> |
| 147 function.</td> | 126 </dl> |
| 148 <td>An implementation of | 127 </td> |
| 149 this function | 128 <td>An implementation of this function |
| 150 examines the input | 129 examines the input event type and |
| 151 event type and | |
| 152 branches accordingly.</td> | 130 branches accordingly.</td> |
| 153 </tr> | 131 </tr> |
| 154 </tbody> | 132 </tbody> |
| 155 </table> | 133 </table> |
| 156 <p>These interfaces are found in the <a class="reference external" href="/native
-client/pepper_stable/cpp/classpp_1_1_instance">pp::Instance class</a>. The sec
tions below | 134 <p>These interfaces are found in the <a class="reference external" href="/native
-client/pepper_stable/cpp/classpp_1_1_instance">pp::Instance class</a>. The sec
tions below |
| 157 provide examples of how to handle these events.</p> | 135 provide examples of how to handle these events.</p> |
| 158 <h2 id="handling-browser-events">Handling browser events</h2> | 136 <h2 id="handling-browser-events">Handling browser events</h2> |
| 159 <h3 id="didchangeview">DidChangeView()</h3> | 137 <h3 id="didchangeview">DidChangeView()</h3> |
| 160 <p>In the <code>mouse_lock</code> example, <code>DidChangeView()</code> checks t
he previous size | 138 <p>In the <code>mouse_lock</code> example, <code>DidChangeView()</code> checks t
he previous size |
| 161 of instance’s rectangle versus the new size. It also compares | 139 of instance’s rectangle versus the new size. It also compares |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 </ul> | 303 </ul> |
| 326 <h3 id="threading-and-blocking">Threading and blocking</h3> | 304 <h3 id="threading-and-blocking">Threading and blocking</h3> |
| 327 <p><code>HandleInputEvent()</code> in this example runs on the main module threa
d. | 305 <p><code>HandleInputEvent()</code> in this example runs on the main module threa
d. |
| 328 However, the bulk of the work happens on a separate worker thread (see | 306 However, the bulk of the work happens on a separate worker thread (see |
| 329 <code>ProcessEventOnWorkerThread</code>). <code>HandleInputEvent()</code> puts e
vents in | 307 <code>ProcessEventOnWorkerThread</code>). <code>HandleInputEvent()</code> puts e
vents in |
| 330 the <code>event_queue_</code> and the worker thread takes events from the | 308 the <code>event_queue_</code> and the worker thread takes events from the |
| 331 <code>event_queue_</code>. This processing happens independently of the main | 309 <code>event_queue_</code>. This processing happens independently of the main |
| 332 thread, so as not to slow down the browser.</p> | 310 thread, so as not to slow down the browser.</p> |
| 333 </section> | 311 </section> |
| 334 | 312 |
| 335 {{/partials.standard_nacl_api}} | 313 {{/partials.standard_nacl_article}} |
| OLD | NEW |