Expand description
An abstraction over the OpenHarmony XComponent
§Example
pub extern "C" fn on_surface_created_cb(xcomponent: *mut OH_NativeXComponent, window: *mut c_void) {
let xc = xcomponent::XComponent::new(xcomponent, window).expect("Invalid XC");
let size = xc.size();
// do something with the xcomponent ...
}
pub extern "C" fn on_dispatch_touch_event_cb(
component: *mut OH_NativeXComponent,
window: *mut c_void,
) {
let xc = xcomponent::XComponent::new(component, window).unwrap();
let touch_event = xc.get_touch_event().unwrap();
// Handle the touch event ....
}
§Features
- log: Outputs error and diagnostic messages via the
log
crate if enabled. - register: Add
register_xcomponent_callbacks
function to register XComponent callbacks.