Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Mouse pointer moves to centre of canvas on click in OpenGL3 with Swing

未关闭
#2,327 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
java
领域
desktop

调研方向

首先使用 JME 3.7.0-stable、嵌入 Swing 的 OpenGL3 canvas,以及一个 InputManager.addListener(ActionListener) 处理程序复现该问题。比较 mouseDown 和 mouseUp 期间的 InputManager.getCursorPosition(),然后对照 OpenGL2 的行为调查 OpenGL3 Swing canvas 的输入路径。完成的标准是光标保持在其物理位置,并且两个事件都在不使用 Robot workaround 的情况下报告预期坐标。

由索引模型根据 Issue 内容生成。

描述

With JME3.7 we can now embed OpenGL3 canvas in a Swing window. I have noticed an issue with the mouse with this configuration.

Steps to reproduce:

  1. Use JME 3.7.0-stable
  2. Be running OpenGL3
  3. Have a jme canvas embedded in a swing window
  4. Listen for jme mouse events using InputManager.addListener(ActionListener)
  5. Left click on the canvas
  6. In the ActionListener, get the position of the mouse using InputManager.getCursorPosition()

Observed
The mouseDown (i.e. keyPressed=true) will have the correct mouse position.
By the time the mouseUp event is processed (i.e. keyPressed=false), the position of the mouse has been moved to the centre of the canvas.

  • The mouse is physically displayed in the centre of the canvas
  • InputManager.getCursorPosition() will return a mouse position in the centre of the canvas

Notes:

  • This does not happen if you are not using Swing
  • This does not happen in OpenGL2 with Swing
  • Seen on both Windows 10 and current Debian linux stable (12.7)

A workaround (more a hack) is to

  • Store the location of the mousedown event
  • In the mouseup event, use java.awt.Robot to move the mouse back to where the mousedown event happened.
主要语言
Java
星标
4.3k
派生
1.2k
平均合并
10 小时 15 分钟
30 天内合并 PR
19

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

jMonkeyEngine/jmonkeyengine 的其他 Issue

查看 jMonkeyEngine/jmonkeyengine 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。