processing / processing/processing4

keyPressed() does not always fire after starting sketch

未关闭
#766 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
494
派生
183
平均合并
4 小时 39 分钟
30 天内合并 PR
3

描述

Created by: sterretjeToo

When starting a sketch from the IDE or running an exported sketch, it does not always react on keyboard input; sometimes one has to click inside the drawn area. So it looks like a started sketch does not have the focus; clicking on the titlebar in the window does not solve the issue.

The below sketch (running in the IDE) produces the issue (as said, it sometimes works correctly, sometime not).

void setup()
{
  size(400, 200);
}

void draw()
{
}

void keyPressed()
{
  println("keyPressed()");
}

Expected behaviour

The expected behaviour is that at the moment that the sketch runs and a key is pressed, the message "keyPressed()" shows.

System information

Second gen Intel I3 with 8GB memory and integrated Intel Graphics (AsRock H61M VS-R2.0)
Windows 10 Home
Processing 4.3; the issue was also observed in Processing 4.2)

Workaround

https://discourse.processing.org/t/keypressed-only-works-sometimes/22340 (July 1920) contains a (possible) workaround by using the below line in setup()

  surface.setVisible(true);

For now, it seems to have solved the issue. I will provide feedback if I still encounter the issue with the above workaround.

贡献指南

打开贡献指南

从这里开始

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

调研方向

在 Windows 上分别从 IDE 和导出的 sketch 运行所提供的最小 sketch,测试无需点击绘图区域时 keyPressed() 是否会立即触发。首先比较 sketch 的启动行为以及窗口的焦点/可见性行为,包括报告中的 workaround surface.setVisible(true)。当两种情况下键盘输入都能在启动后立即可靠工作时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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