简体   繁体   English

如何在 Windows 的 Rust 板条箱中为 CoreApp 注册 PointerPressed 事件处理程序?

[英]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 satisfied error message 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) {
    //...
}

The above code now builds with the following edits to the end of the SetWindow function and the OnPointerPressed function:上面的代码现在通过对 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.

相关问题 我应该尝试在 Windows 的 Rust Crate 中的 CoreApp 的 PointerPressed 事件处理程序中访问 self 吗? - Should I try to access self in a PointerPressed event handler for a CoreApp in the Rust Crate for Windows? 如何使用 Windows 的 Rust 板条箱将 CompositionTarget 初始化为 null? - How do I initialize a CompositionTarget to null using the Rust Crate for Windows? 您如何将 PostMessage 与 windows-rs 板条箱一起使用? - How do you use PostMessage with the windows-rs crate? 如何为 RegGetValueW 分配内存(通过 Windows crate for Rust) - How to allocate memory for RegGetValueW (via the Windows crate for Rust) 从 Rust Windows 二进制包导出 function - Export function from Rust Windows binary crate 如何在 c# 中安全地注册事件处理程序? - How to register event handler safe in c#? 如何分配空间以使用 windows 板条箱调用 GetInterfaceInfo? - How do I allocate space to call GetInterfaceInfo using the windows crate? 如何在Windows中注册最近使用的列表以准备Windows 7? - How do you register a Most Recently Used list with Windows in preparation for Windows 7? 如何在Windows中注册COM(组件对象模型)? (用于图标叠加处理程序) - How to register a COM (Component Object Model) in Windows? (for Icon Overlay Handler) 错误 [E0463]: can&#39;t find crate for std... 如何在 x64 Windows 机器上编译 Rust x32? - Error[E0463]: can't find crate for std... how to compile Rust x32 in a x64 Windows machine?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM