• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Native XComponent
2
3
4## Overview
5
6Describes the surface and touch event held by the ArkUI XComponent, which can be used for the EGL/OpenGL ES and media data input and displayed on the ArkUI XComponent.
7
8
9**Since:**
108
11
12## Summary
13
14
15### Files
16
17| Name | Description |
18| -------- | -------- |
19| [native_interface_xcomponent.h](native__interface__xcomponent_8h.md) | Declare the APIs used to access the native XComponent.<br>File to Include: <ace/xcomponent/native_interface_xcomponent.h>  |
20
21
22### Structs
23
24| Name | Description |
25| -------- | -------- |
26| [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) |  Describes the touch point of the touch event. |
27| [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) | Describes the touch event.  |
28| [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) | Describes the mouse event.  |
29| [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) | Registers a callback for the surface lifecycle and touch event.  |
30| [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) | Registers a callback for the mouse event.  |
31
32
33### Types
34
35| Name | Description |
36| -------- | -------- |
37| [OH_NativeXComponent](#oh_nativexcomponent)                  | Provides an encapsulated OH_NativeXComponent instance. |
38| [OH_NativeXComponent_Callback](#oh_nativexcomponent_callback) | Registers a callback for the surface lifecycle and touch event. |
39| [OH_NativeXComponent_MouseEvent_Callback](#oh_nativexcomponent_mouseevent_callback) | Registers a callback for the mouse event.   |
40
41
42### Enums
43
44| Name | Description |
45| -------- | -------- |
46| {OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, <br>OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, <br/>OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2 } | [Enumerates](#anonymous-enum) the API access states. |
47| [OH_NativeXComponent_TouchEventType](#oh_nativexcomponent_toucheventtype) {  <br/>OH_NATIVEXCOMPONENT_DOWN = 0, <br/>OH_NATIVEXCOMPONENT_UP, <br/>OH_NATIVEXCOMPONENT_MOVE, <br/>OH_NATIVEXCOMPONENT_CANCEL,<br/>OH_NATIVEXCOMPONENT_UNKNOWN } | Enumerates the touch event types.   |
48| [OH_NativeXComponent_TouchPointToolType](#oh_nativexcomponent_touchpointtooltype) {<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE,<br/>OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS } | Enumerates the contact point tool types. |
49| [OH_NativeXComponent_EventSourceType](#oh_nativexcomponent_eventsourcetype) {<br/>OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0,<br/>OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN,<br/>OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD,<br/>OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK} | Enumerates the source types of the touch event. |
50| [OH_NativeXComponent_MouseEventAction](#oh_nativexcomponent_mouseeventaction) { <br/>OH_NATIVEXCOMPONENT_MOUSE_NONE = 0, <br/>OH_NATIVEXCOMPONENT_MOUSE_PRESS, <br/>OH_NATIVEXCOMPONENT_MOUSE_RELEASE, <br/>OH_NATIVEXCOMPONENT_MOUSE_MOVE } | Enumerates the mouse event actions.        |
51| [OH_NativeXComponent_MouseEventButton](#oh_nativexcomponent_mouseeventbutton) {  <br/>OH_NATIVEXCOMPONENT_NONE_BUTTON = 0, <br/>OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01, <br/>OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02, <br/>OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04,   <br/>OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08, <br/>OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10 } | Enumerates the mouse event buttons.   |
52
53
54### Functions
55
56| Name | Description |
57| -------- | -------- |
58| [OH_NativeXComponent_GetXComponentId](#oh_nativexcomponent_getxcomponentid) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, char \*id, uint64_t \*size) | Obtains the ID of the ArkUI XComponent.   |
59| [OH_NativeXComponent_GetXComponentSize](#oh_nativexcomponent_getxcomponentsize) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, uint64_t \*width, uint64_t \*height) | Obtains the size of the surface held by the ArkUI XComponent.  |
60| [OH_NativeXComponent_GetXComponentOffset](#oh_nativexcomponent_getxcomponentoffset) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, double \*x, double \*y) | Obtains the offset of the ArkUI XComponent relative to the upper left vertex of the screen. |
61| [OH_NativeXComponent_GetTouchEvent](#oh_nativexcomponent_gettouchevent) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) \*touchEvent) | Obtains the touch event scheduled by the ArkUI XComponent.              |
62| [OH_NativeXComponent_GetTouchPointToolType](#oh_nativexcomponent_gettouchpointtooltype) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, uint32_t pointIndex, [OH_NativeXComponent_TouchPointToolType](#oh_nativexcomponent_touchpointtooltype) \*toolType) | Obtains the ArkUI XComponent touch point tool type. |
63| [OH_NativeXComponent_GetTouchPointTiltX](#oh_nativexcomponent_gettouchpointtiltx) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, uint32_t pointIndex, float \*tiltX) | Obtains the angle between the tilt of the ArkUI XComponent touch point and the x-axis. |
64| [OH_NativeXComponent_GetTouchPointTiltY](#oh_nativexcomponent_gettouchpointtilty) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, uint32_t pointIndex, float \*tiltY) | Obtains the angle between the tilt of the ArkUI XComponent touch point and the y-axis. |
65| [OH_NativeXComponent_GetMouseEvent](#oh_nativexcomponent_getmouseevent) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) \*mouseEvent) | Obtains the mouse event scheduled by ArkUI XComponent.   |
66| [OH_NativeXComponent_RegisterCallback](#oh_nativexcomponent_registercallback) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) \*callback) | Registers a callback for this **OH_NativeXComponent** instance.  |
67| [OH_NativeXComponent_RegisterMouseEventCallback](#oh_nativexcomponent_registermouseeventcallback) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) \*callback) | Registers a mouse event callback for this **OH_NativeXComponent** instance.     |
68
69
70### Variables
71
72| Name | Description |
73| -------- | -------- |
74| [OH_XCOMPONENT_ID_LEN_MAX](#oh_xcomponent_id_len_max) = 128  | Maximum length of an ArkUI XComponent ID.   |
75| [OH_MAX_TOUCH_POINTS_NUMBER](#oh_max_touch_points_number) = 10 | Maximum number of identifiable touch points in a touch event. |
76| [OH_NativeXComponent_TouchPoint::id](#id-12) = 0             | Unique identifier of the finger.  |
77| [OH_NativeXComponent_TouchPoint::screenX](#screenx-13) = 0.0 | X coordinate of the touch point relative to the left edge of the screen.     |
78| [OH_NativeXComponent_TouchPoint::screenY](#screeny-13) = 0.0 | Y coordinate of the touch point relative to the left edge of the screen.    |
79| [OH_NativeXComponent_TouchPoint::x](#x-13) = 0.0             | X coordinate of the touch point relative to the left edge of the XComponent. |
80| [OH_NativeXComponent_TouchPoint::y](#y-13) = 0.0             | Y coordinate of the touch point relative to the upper edge of the XComponent. |
81| [OH_NativeXComponent_TouchPoint::type](#type-12) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event.      |
82| [OH_NativeXComponent_TouchPoint::size](#size-12) = 0.0       | Contact area between the finger pad and the screen. |
83| [OH_NativeXComponent_TouchPoint::force](#force-12) = 0.0     | Pressure of the current touch event.    |
84| [OH_NativeXComponent_TouchPoint::timeStamp](#timestamp-12) = 0 | Timestamp of the current touch event.     |
85| [OH_NativeXComponent_TouchPoint::isPressed](#ispressed) = false | Whether the current point is pressed.      |
86| [OH_NativeXComponent_TouchEvent::id](#id-22) = 0             | Unique identifier of the finger.   |
87| [OH_NativeXComponent_TouchEvent::screenX](#screenx-23) = 0.0 | X coordinate of the touch point relative to the left edge of the screen.  |
88| [OH_NativeXComponent_TouchEvent::screenY](#screeny-23) = 0.0 | Y coordinate of the touch point relative to the left edge of the screen.  |
89| [OH_NativeXComponent_TouchEvent::x](#x-23) = 0.0             | X coordinate of the touch point relative to the left edge of the XComponent. |
90| [OH_NativeXComponent_TouchEvent::y](#y-23) = 0.0             | Y coordinate of the touch point relative to the upper edge of the XComponent. |
91| [OH_NativeXComponent_TouchEvent::type](#type-22) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event.    |
92| [OH_NativeXComponent_TouchEvent::size](#size-22) = 0.0       | Contact area between the finger pad and the screen.    |
93| [OH_NativeXComponent_TouchEvent::force](#force-22) = 0.0     | Pressure of the current touch event.  |
94| [OH_NativeXComponent_TouchEvent::deviceId](#deviceid) = 0    | ID of the device where the current touch event is triggered.  |
95| [OH_NativeXComponent_TouchEvent::timeStamp](#timestamp-22) = 0 | Timestamp of the current touch event.  |
96| [OH_NativeXComponent_TouchEvent::touchPoints](#touchpoints) [OH_MAX_TOUCH_POINTS_NUMBER] | Array of the current touch points.   |
97| [OH_NativeXComponent_TouchEvent::numPoints](#numpoints) = 0  | Number of current touch points.    |
98| [OH_NativeXComponent_MouseEvent::x](#x-33) = 0.0             | X coordinate of the clicked point relative to the upper left corner of the component. |
99| [OH_NativeXComponent_MouseEvent::y](#y-33) = 0.0             | Y coordinate of the clicked point relative to the upper left corner of the component. |
100| [OH_NativeXComponent_MouseEvent::screenX](#screenx-33) = 0.0 | X coordinate of the clicked point relative to the upper left corner of the screen.  |
101| [OH_NativeXComponent_MouseEvent::screenY](#screeny-33) = 0.0 | Y coordinate of the clicked point relative to the upper left corner of the screen.  |
102| [OH_NativeXComponent_MouseEvent::timestamp](#timestamp) = 0  | Timestamp of the current mouse event.  |
103| [OH_NativeXComponent_MouseEvent::action](#action) = [OH_NativeXComponent_MouseEventAction::OH_NATIVEXCOMPONENT_MOUSE_NONE](#oh_nativexcomponent_mouseeventaction) | Current mouse event action.   |
104| [OH_NativeXComponent_MouseEvent::button](#button) = [OH_NativeXComponent_MouseEventButton::OH_NATIVEXCOMPONENT_NONE_BUTTON](#oh_nativexcomponent_mouseeventbutton) | Mouse event button |
105| [OH_NativeXComponent_Callback::OnSurfaceCreated](#onsurfacecreated) | Invoked when a surface is created.  |
106| [OH_NativeXComponent_Callback::OnSurfaceChanged](#onsurfacechanged) | Invoked when the surface changes.    |
107| [OH_NativeXComponent_Callback::OnSurfaceDestroyed](#onsurfacedestroyed) |  Invoked when the surface is destroyed.          |
108| [OH_NativeXComponent_Callback::DispatchTouchEvent](#dispatchtouchevent) | Invoked when a touch event is triggered.  |
109| [OH_NativeXComponent_MouseEvent_Callback::DispatchMouseEvent](#dispatchmouseevent) | Invoked when a mouse event is triggered.     |
110| [OH_NativeXComponent_MouseEvent_Callback::DispatchHoverEvent](#dispatchhoverevent) | Invoked when a hover event is triggered.     |
111
112
113## Type Description
114
115### OH_NativeXComponent
116
117
118```
119typedef struct OH_NativeXComponent OH_NativeXComponent
120```
121
122**Description**
123
124Provides an encapsulated OH_NativeXComponent instance.
125
126**Since:**
127
1288
129
130
131### OH_NativeXComponent_Callback
132
133
134```
135typedef struct OH_NativeXComponent_Callback OH_NativeXComponent_Callback
136```
137
138**Description**
139
140Registers a callback for the surface lifecycle and touch event.
141
142**Since:**
143
1448
145
146
147### OH_NativeXComponent_MouseEvent_Callback
148
149
150```
151typedef struct OH_NativeXComponent_MouseEvent_Callback OH_NativeXComponent_MouseEvent_Callback
152```
153
154**Description**
155
156Registers a callback for the mouse event.
157
158**Since:**
159
1609
161
162
163## Enum Description
164
165### anonymous enum
166
167
168```
169anonymous enum
170```
171
172**Description**
173
174Enumerates the API access states.
175
176| Name                                   | Description       |
177| ---------------------------------------- | ---------- |
178| OH_NATIVEXCOMPONENT_RESULT_SUCCESS       | Success result. |
179| OH_NATIVEXCOMPONENT_RESULT_FAILED        | Failure. |
180| OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER | Invalid parameter. |
181
182**Since:**
183
1848
185
186### OH_NativeXComponent_EventSourceType
187
188OH_NativeXComponent_EventSourceType
189
190
191```
192enum OH_NativeXComponent_EventSourceType
193```
194
195**Description**
196
197Enumerates the source types of the touch event.
198
199| Name | Description |
200| -------- | -------- |
201| OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN | Unknown source type. |
202| OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE | Source that generates a mouse multi-touch event. |
203| OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN | Source that generates a touchscreen multi-touch event. |
204| OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD | Source that generates a touchpad multi-touch event. |
205| OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK | Source that generates a joystick multi-touch event. |
206
207**Since:**
208
2099
210
211### OH_NativeXComponent_MouseEventAction
212
213
214```
215enum OH_NativeXComponent_MouseEventAction
216```
217
218**Description**
219
220Enumerates the mouse event actions.
221
222| Name                            | Description                             |
223| --------------------------------- | -------------------------------- |
224| OH_NATIVEXCOMPONENT_MOUSE_NONE    | Invalid mouse event.                  |
225| OH_NATIVEXCOMPONENT_MOUSE_PRESS   | The mouse event is triggered when a mouse button is pressed.    |
226| OH_NATIVEXCOMPONENT_MOUSE_RELEASE | The mouse event is triggered when a mouse button is released.     |
227| OH_NATIVEXCOMPONENT_MOUSE_MOVE    | The mouse event is triggered when the mouse moves on the screen. |
228
229**Since:**
230
2319
232
233
234### OH_NativeXComponent_MouseEventButton
235
236
237```
238enum OH_NativeXComponent_MouseEventButton
239```
240
241**Description**
242
243Enumerates the mouse event buttons.
244
245| Name                             | Description                               |
246| ---------------------------------- | ---------------------------------- |
247| OH_NATIVEXCOMPONENT_NONE_BUTTON    | The mouse event is triggered when no mouse button is pressed.     |
248| OH_NATIVEXCOMPONENT_LEFT_BUTTON    | The mouse event is triggered when the left mouse button is pressed.  |
249| OH_NATIVEXCOMPONENT_RIGHT_BUTTON   | The mouse event is triggered when the right mouse button is pressed.       |
250| OH_NATIVEXCOMPONENT_MIDDLE_BUTTON  | The mouse event is triggered when the middle mouse button is pressed.   |
251| OH_NATIVEXCOMPONENT_BACK_BUTTON    | The mouse event is triggered when the back button on the left of the mouse is pressed. |
252| OH_NATIVEXCOMPONENT_FORWARD_BUTTON | The mouse event is triggered when the forward button on the left of the mouse is pressed. |
253
254**Since:**
255
2569
257
258
259### OH_NativeXComponent_TouchEventType
260
261
262```
263enum OH_NativeXComponent_TouchEventType
264```
265
266**Description**
267
268Enumerates the touch event types.
269
270| Name                      | Description                                       |
271| --------------------------- | ------------------------------------------ |
272| OH_NATIVEXCOMPONENT_DOWN    | The touch event is triggered when a finger is pressed.    |
273| OH_NATIVEXCOMPONENT_UP      | The touch event is triggered when a finger is lifted.  |
274| OH_NATIVEXCOMPONENT_MOVE    | The touch event is triggered when a finger is pressed and moves on the screen.  |
275| OH_NATIVEXCOMPONENT_CANCEL  | The event is triggered when a touch event is canceled.         |
276| OH_NATIVEXCOMPONENT_UNKNOWN | Invalid touch type.       |
277
278**Since:**
279
2808
281
282### OH_NativeXComponent_TouchPointToolType
283
284
285```
286enum OH_NativeXComponent_TouchPointToolType
287```
288
289**Description**
290
291Enumerates the contact point tool types.
292
293| Name | Description |
294| -------- | -------- |
295| OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN | Unknown tool type. |
296| OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER | Finger. |
297| OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN | Stylus. |
298| OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER | Eraser. |
299| OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH | Brush. |
300| OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL | Pencil. |
301| OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH | Air brush. |
302| OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE | Mouse. |
303| OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS | Lens. |
304
305**Since:**
306
3079
308
309
310## Function Description
311
312
313### OH_NativeXComponent_GetMouseEvent()
314
315
316```
317int32_t OH_NativeXComponent_GetMouseEvent (OH_NativeXComponent * component, const void * window, OH_NativeXComponent_MouseEvent * mouseEvent )
318```
319
320**Description**
321
322Obtains the mouse event scheduled by ArkUI XComponent.
323
324**Parameters**
325
326| Name       | Description                                    |
327| ---------- | --------------------------------------- |
328| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
329| window     | Indicates the pointer to a **NativeWindow** handle.                  |
330| mouseEvent | Indicates the pointer to the current mouse event.     |
331
332**Returns**
333
334Returns the status code of the operation.
335
336**Since:**
337
3389
339
340
341### OH_NativeXComponent_GetTouchEvent()
342
343
344```
345int32_t OH_NativeXComponent_GetTouchEvent (OH_NativeXComponent * component, const void * window, OH_NativeXComponent_TouchEvent * touchEvent )
346```
347
348**Description**
349
350Obtains the touch event scheduled by the ArkUI XComponent.
351
352**Parameters**
353
354| Name       | Description                                    |
355| ---------- | --------------------------------------- |
356| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
357| window     | Indicates the pointer to a **NativeWindow** handle.                  |
358| touchEvent | Indicates the pointer to the current touch event.           |
359
360**Returns**
361
362Returns the status code of the operation.
363
364**Since:**
365
3668
367
368### OH_NativeXComponent_GetTouchPointTiltX()
369
370
371```
372int32_t OH_NativeXComponent_GetTouchPointTiltX (OH_NativeXComponent * component, uint32_t pointIndex, float * tiltX )
373```
374
375**Description**
376
377Obtains the angle between the tilt of the ArkUI XComponent touch point and the x-axis.
378
379**Parameters**
380
381| Name | Description |
382| -------- | -------- |
383| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
384| pointIndex | Indicates the index of the pointer to a touch point. |
385| tiltX | Indicates the pointer to the tilt along the x-axis. |
386
387**Returns**
388
389Returns the status code of the operation.
390
391**Since:**
392
3939
394
395
396### OH_NativeXComponent_GetTouchPointTiltY()
397
398
399```
400int32_t OH_NativeXComponent_GetTouchPointTiltX (OH_NativeXComponent * component, uint32_t pointIndex, float * tiltY )
401```
402
403**Description**
404
405Obtains the angle between the tilt of the ArkUI XComponent touch point and the y-axis.
406
407**Parameters**
408
409| Name | Description |
410| -------- | -------- |
411| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
412| pointIndex | Indicates the index of the pointer to a touch point. |
413| tiltY | Indicates the pointer to the tilt along the y-axis. |
414
415**Returns**
416
417Returns the status code of the operation.
418
419**Since:**
420
4219
422
423
424### OH_NativeXComponent_GetTouchPointToolType()
425
426
427```
428int32_t OH_NativeXComponent_GetTouchPointToolType (OH_NativeXComponent * component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType * toolType )
429```
430
431**Description**
432
433Obtains the ArkUI XComponent touch point tool type.
434
435**Parameters**
436
437| Name | Description |
438| -------- | -------- |
439| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
440| pointIndex | Indicates the index of the pointer to a touch point. |
441| toolType | Indicates the pointer to the tool type. |
442
443**Returns**
444
445Returns the status code of the operation.
446
447**Since:**
448
4499
450
451
452### OH_NativeXComponent_GetXComponentId()
453
454
455```
456int32_t OH_NativeXComponent_GetXComponentId (OH_NativeXComponent * component, char * id, uint64_t * size )
457```
458
459**Description**
460
461Obtains the ID of the ArkUI XComponent.
462
463**Parameters**
464
465| Name      | Description    |
466| --------- | ------------------------------------- |
467| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
468| id        | Indicates the pointer to the character buffer used to hold the ID of the OH_NativeXComponent instance.<br>Note that the null terminator is attached to the character buffer, so the size of the character buffer should be at least one unit greater than the length of the real ID.<br>The recommended size of the character buffer is [OH_XCOMPONENT_ID_LEN_MAX + 1]. |
469| size      | Indicates the pointer to the length of the ID.         |
470
471**Returns**
472
473Returns the status code of the operation.
474
475**Since:**
476
4778
478
479
480### OH_NativeXComponent_GetXComponentOffset()
481
482
483```
484int32_t OH_NativeXComponent_GetXComponentOffset (OH_NativeXComponent * component, const void * window, double * x, double * y )
485```
486
487**Description**
488
489Obtains the offset of the ArkUI XComponent relative to the upper left vertex of the screen.
490
491**Parameters**
492
493| Name      | Description                                    |
494| --------- | --------------------------------------- |
495| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
496| window    | Indicates the pointer to a **NativeWindow** handle.  |
497| x         | Indicates the pointer to the x coordinate of the current surface.    |
498| y         | Indicates the pointer to the y coordinate of the current surface.      |
499
500**Returns**
501
502Returns the status code of the operation.
503
504**Since:**
505
5068
507
508
509### OH_NativeXComponent_GetXComponentSize()
510
511
512```
513int32_t OH_NativeXComponent_GetXComponentSize (OH_NativeXComponent * component, const void * window, uint64_t * width, uint64_t * height )
514```
515
516**Description**
517
518Obtains the size of the surface held by the ArkUI XComponent.
519
520**Parameters**
521
522| Name      | Description                                    |
523| --------- | --------------------------------------- |
524| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
525| window    | Indicates the pointer to a **NativeWindow** handle.  |
526| width     | Indicates the pointer to the width of the current surface. |
527| height    | Indicates the pointer to the height of the current surface.   |
528
529**Returns**
530
531Returns the status code of the operation.
532
533**Since:**
534
5358
536
537
538### OH_NativeXComponent_RegisterCallback()
539
540
541```
542int32_t OH_NativeXComponent_RegisterCallback (OH_NativeXComponent * component, OH_NativeXComponent_Callback * callback )
543```
544
545**Description**
546
547Registers a callback for this **OH_NativeXComponent** instance.
548
549**Parameters**
550
551| Name      | Description                                          |
552| --------- | --------------------------------------------- |
553| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
554| callback  | Indicates the pointer to the surface lifecycle and touch event callback.|
555
556**Returns**
557
558Returns the status code of the operation.
559
560**Since:**
561
5628
563
564
565### OH_NativeXComponent_RegisterMouseEventCallback()
566
567
568```
569int32_t OH_NativeXComponent_RegisterMouseEventCallback (OH_NativeXComponent * component, OH_NativeXComponent_MouseEvent_Callback * callback )
570```
571
572**Description**
573
574Registers a mouse event callback for this **OH_NativeXComponent** instance.
575
576**Parameters**
577
578| Name      | Description                                    |
579| --------- | --------------------------------------- |
580| component  | Indicates the pointer to an **OH_NativeXComponent** instance. |
581| callback  | Indicates the pointer to the mouse event callback.    |
582
583**Returns**
584
585Returns the status code of the operation.
586
587**Since:**
588
5899
590
591
592## Variable Description
593
594
595### OH_XCOMPONENT_ID_LEN_MAX
596
597
598```
599const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128
600```
601
602**Description**
603
604Maximum length of an ArkUI XComponent ID.
605
606**Since:**
607
6088
609
610
611### OH_MAX_TOUCH_POINTS_NUMBER
612
613
614```
615const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10
616```
617
618**Description**
619
620Maximum number of identifiable touch points in a touch event.
621
622**Since:**
623
6248
625
626
627### action
628
629
630```
631OH_NativeXComponent_MouseEventAction OH_NativeXComponent_MouseEvent::action
632```
633
634**Description**
635
636Current mouse event action.
637
638**Since:**
639
6408
641
642
643### button
644
645
646```
647OH_NativeXComponent_MouseEventButton OH_NativeXComponent_MouseEvent::button
648```
649
650**Description**
651
652Mouse event button
653
654**Since:**
655
6568
657
658
659### deviceId
660
661
662```
663int64_t OH_NativeXComponent_TouchEvent::deviceId = 0
664```
665
666**Description**
667
668ID of the device where the current touch event is triggered.
669
670**Since:**
671
6728
673
674
675### DispatchHoverEvent
676
677
678```
679void(* OH_NativeXComponent_MouseEvent_Callback::DispatchHoverEvent) (OH_NativeXComponent *component, bool isHover)
680```
681
682**Description**
683
684Invoked when a hover event is triggered.
685
686**Since:**
687
6888
689
690
691### DispatchMouseEvent
692
693
694```
695void(* OH_NativeXComponent_MouseEvent_Callback::DispatchMouseEvent) (OH_NativeXComponent *component, void *window)
696```
697
698**Description**
699
700Invoked when a mouse event is triggered.
701
702**Since:**
703
7048
705
706
707### DispatchTouchEvent
708
709
710```
711void(* OH_NativeXComponent_Callback::DispatchTouchEvent) (OH_NativeXComponent *component, void *window)
712```
713
714**Description**
715
716Invoked when a touch event is triggered.
717
718**Since:**
719
7208
721
722
723### force [1/2]
724
725
726```
727float OH_NativeXComponent_TouchPoint::force = 0.0
728```
729
730**Description**
731
732Pressure of the current touch event.
733
734**Since:**
735
7368
737
738
739### force [2/2]
740
741
742```
743float OH_NativeXComponent_TouchEvent::force = 0.0
744```
745
746**Description**
747
748Pressure of the current touch event.
749
750**Since:**
751
7528
753
754
755### id [1/2]
756
757
758```
759int32_t OH_NativeXComponent_TouchPoint::id = 0
760```
761
762**Description**
763
764Unique identifier of the finger.
765
766**Since:**
767
7688
769
770
771### id [2/2]
772
773
774```
775int32_t OH_NativeXComponent_TouchEvent::id = 0
776```
777
778**Description**
779
780Unique identifier of the finger.
781
782**Since:**
783
7848
785
786
787### isPressed
788
789
790```
791bool OH_NativeXComponent_TouchPoint::isPressed = false
792```
793
794**Description**
795
796Whether the current point is pressed.
797
798**Since:**
799
8008
801
802
803### numPoints
804
805
806```
807uint32_t OH_NativeXComponent_TouchEvent::numPoints = 0
808```
809
810**Description**
811
812Number of current touch points.
813
814**Since:**
815
8168
817
818
819### OnSurfaceChanged
820
821
822```
823void(* OH_NativeXComponent_Callback::OnSurfaceChanged) (OH_NativeXComponent *component, void *window)
824```
825
826**Description**
827
828Invoked when the surface changes.
829
830**Since:**
831
8328
833
834
835### OnSurfaceCreated
836
837
838```
839void(* OH_NativeXComponent_Callback::OnSurfaceCreated) (OH_NativeXComponent *component, void *window)
840```
841
842**Description**
843
844Invoked when a surface is created.
845
846**Since:**
847
8488
849
850
851### OnSurfaceDestroyed
852
853
854```
855void(* OH_NativeXComponent_Callback::OnSurfaceDestroyed) (OH_NativeXComponent *component, void *window)
856```
857
858**Description**
859
860Invoked when the surface is destroyed.
861
862**Since:**
863
8648
865
866
867### screenX [1/3]
868
869
870```
871float OH_NativeXComponent_TouchPoint::screenX = 0.0
872```
873
874**Description**
875
876X coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located.
877
878**Since:**
879
8808
881
882
883### screenX [2/3]
884
885
886```
887float OH_NativeXComponent_TouchEvent::screenX = 0.0
888```
889
890**Description**
891
892X coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located.
893
894**Since:**
895
8968
897
898
899### screenX [3/3]
900
901
902```
903float OH_NativeXComponent_MouseEvent::screenX
904```
905
906**Description**
907
908X coordinate of the clicked point relative to the upper left corner of the screen.
909
910**Since:**
911
9128
913
914
915### screenY [1/3]
916
917
918```
919float OH_NativeXComponent_TouchPoint::screenY = 0.0
920```
921
922**Description**
923
924Y coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located.
925
926**Since:**
927
9288
929
930
931### screenY [2/3]
932
933
934```
935float OH_NativeXComponent_TouchEvent::screenY = 0.0
936```
937
938**Description**
939
940Y coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located.
941
942**Since:**
943
9448
945
946
947### screenY [3/3]
948
949
950```
951float OH_NativeXComponent_MouseEvent::screenY
952```
953
954**Description**
955
956Y coordinate of the clicked point relative to the upper left corner of the screen.
957
958**Since:**
959
9608
961
962
963### size [1/2]
964
965
966```
967double OH_NativeXComponent_TouchPoint::size = 0.0
968```
969
970**Description**
971
972Contact area between the finger pad and the screen.
973
974**Since:**
975
9768
977
978
979### size [2/2]
980
981
982```
983double OH_NativeXComponent_TouchEvent::size = 0.0
984```
985
986**Description**
987
988Contact area between the finger pad and the screen.
989
990**Since:**
991
9928
993
994
995### timeStamp [1/2]
996
997
998```
999long long OH_NativeXComponent_TouchPoint::timeStamp = 0
1000```
1001
1002**Description**
1003
1004Timestamp of the current touch event.
1005
1006**Since:**
1007
10088
1009
1010
1011### timeStamp [2/2]
1012
1013
1014```
1015long long OH_NativeXComponent_TouchEvent::timeStamp = 0
1016```
1017
1018**Description**
1019
1020Timestamp of the current touch event.
1021
1022**Since:**
1023
10248
1025
1026
1027### timestamp
1028
1029
1030```
1031int64_t OH_NativeXComponent_MouseEvent::timestamp
1032```
1033
1034**Description**
1035
1036Timestamp of the current mouse event.
1037
1038**Since:**
1039
10408
1041
1042
1043### touchPoints
1044
1045
1046```
1047OH_NativeXComponent_TouchPoint OH_NativeXComponent_TouchEvent::touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]
1048```
1049
1050**Description**
1051
1052Array of the current touch points.
1053
1054**Since:**
1055
10568
1057
1058
1059### type [1/2]
1060
1061
1062```
1063OH_NativeXComponent_TouchEventType OH_NativeXComponent_TouchPoint::type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN
1064```
1065
1066**Description**
1067
1068Touch type of the touch event.
1069
1070**Since:**
1071
10728
1073
1074
1075### type [2/2]
1076
1077
1078```
1079OH_NativeXComponent_TouchEventType OH_NativeXComponent_TouchEvent::type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN
1080```
1081
1082**Description**
1083
1084Touch type of the touch event.
1085
1086**Since:**
1087
10888
1089
1090
1091### x [1/3]
1092
1093
1094```
1095float OH_NativeXComponent_TouchPoint::x = 0.0
1096```
1097
1098**Description**
1099
1100X coordinate of the touch point relative to the left edge of the XComponent.
1101
1102**Since:**
1103
11048
1105
1106
1107### x [2/3]
1108
1109
1110```
1111float OH_NativeXComponent_TouchEvent::x = 0.0
1112```
1113
1114**Description**
1115
1116X coordinate of the touch point relative to the left edge of the XComponent.
1117
1118**Since:**
1119
11208
1121
1122
1123### x [3/3]
1124
1125
1126```
1127float OH_NativeXComponent_MouseEvent::x
1128```
1129
1130**Description**
1131
1132X coordinate of the clicked point relative to the upper left corner of the component.
1133
1134**Since:**
1135
11368
1137
1138
1139### y [1/3]
1140
1141
1142```
1143float OH_NativeXComponent_TouchPoint::y = 0.0
1144```
1145
1146**Description**
1147
1148Y coordinate of the touch point relative to the upper edge of the XComponent.
1149
1150**Since:**
1151
11528
1153
1154
1155### y [2/3]
1156
1157
1158```
1159float OH_NativeXComponent_TouchEvent::y = 0.0
1160```
1161
1162**Description**
1163
1164Y coordinate of the touch point relative to the upper edge of the XComponent.
1165
1166**Since:**
1167
11688
1169
1170
1171### y [3/3]
1172
1173
1174```
1175float OH_NativeXComponent_MouseEvent::y
1176```
1177
1178**Description**
1179
1180Y coordinate of the clicked point relative to the upper left corner of the component.
1181
1182**Since:**
1183
11848