Godot限制输入字符

extends LineEdit

func _input(event):
	if event is InputEventKey:
		#仅允许汉字输入
		if !(event.unicode >= 0x4E00 && event.unicode <= 0x9FA5):
			get_tree().set_input_as_handled()

常用Unicode编码范围

  • 汉字 [0x4e00,0x9fa5]
  • 数字 [0x30,0x39]
  • 小写字母 [0x61,0x7a]
  • 大写字母 [0x41,0x5a]

猜你喜欢

转载自blog.csdn.net/a363533090/article/details/121735318