Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleGUI::TextBox で Backspace が反応しづらい (Web, Android) #1284

Open
ka-disco opened this issue Jan 16, 2025 · 2 comments
Open

Comments

@ka-disco
Copy link

予期しない動作の内容 | Describe the unexpected behavior
SimpleGUI::TextBox をモバイル環境で使用した際、Backspace の反応がとても悪い。
一文字分反応させるために、数秒~十秒ほど長押しが必要。

再現方法 | To Reproduce
OpenSIv3D for Web で以下のソースをリリースビルドし、サーバ上にデプロイ。
モバイル環境からアクセスする。

# include <Siv3D.hpp>

void Main()
{
	TextEditState textEditState{};

	while (System::Update())
	{
		SimpleGUI::TextBox(textEditState, Vec2{ 10, 10 });
	}
}

発生環境(モバイルの場合) | Smartphone (please complete the following information):

  • デバイス | Device: Xiaomi 12T Pro
  • OS: Xiaomi HyperOS (Android 14)
  • バージョン | Version: OpenSiv3D for Web 0.6.15
  • ブラウザ (Web 版) | Browser: Chrome

備考 | Additional context
Gboard, Simeji 共に同じ症状。

@Reputeless
Copy link
Member

ご報告ありがとうございます。
例えば入力が数字やアルファベット限定であれば、次のような入力パッドを実装することができます。
https://siv3d.github.io/ja-jp/samples/ui/#15-%E6%95%B0%E5%80%A4%E3%83%91%E3%83%83%E3%83%89

@Raclamusi
Copy link
Member

こちらの issue Raclamusi#7 で原因、解決策を調査しています。

応急処置として、以下のコードを Main 関数の冒頭にコピペすることで Backspace キーなどが反応するようになります。

EM_ASM({
	let keyDownEvent = null;
	let timeoutId = null;

	addEventListener("keydown", function(event) {
		if (!event.isTrusted) {
			return;
		}
		keyDownEvent = event;
	});

	addEventListener("keyup", function(event) {
		if (!event.isTrusted) {
			return;
		}
		const keyUpEvent = event;
		if (keyDownEvent.timeStamp == keyUpEvent.timeStamp) {
			clearTimeout(timeoutId);
			dispatchEvent(keyDownEvent);
			timeoutId = setTimeout(function() {
				dispatchEvent(keyUpEvent);
				timeoutId = null;
			}, 100);
		}
	});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants