[英]Should I try to access self in a PointerPressed event handler for a CoreApp in the Rust Crate for Windows?
[英]How do you register a PointerPressed event handler for a CoreApp in the Rust Crate for Windows?
E0277 The trait IntoParam TypeEventHandler<CoreWindow, PointerEventArgs> bound is not compatible 错误信息
fn SetWindow(&mut self, window: &Option<CoreWindow>) -> Result<()> {
let compositor = Compositor::new()?;
let root = compositor.CreateContainerVisual()?;
self.target = Some(compositor.CreateTargetForCurrentView()?);
self.target.as_ref().unwrap().SetRoot(&root)?; // &root
self.visuals = Some(root.Children()?);
//window.unwrap().PointerPressed(handler: Param0)?;
window.unwrap().PointerPressed(Self::OnPointerPressed)?;
Ok(())
}
fn OnPointerPressed(win: CoreWindow, pea: PointerEventArgs) {
//...
}
上面的代码现在通过对 SetWindow function 和 OnPointerPressed function 末尾的以下编辑进行构建:
window.as_ref().unwrap().PointerPressed(
TypedEventHandler::new(Self::OnPointerPressed))?;
Ok(())
}
fn OnPointerPressed(_: &Option<CoreWindow>,
args: &Option<PointerEventArgs>)
-> Result<()> {
Ok(())
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.