瀏覽代碼

Merge pull request #7200 from MisoMosiSpy/input_example_keymodifiers

Max Hilbrunner 2 年之前
父節點
當前提交
f7611bb4ad
共有 3 個文件被更改,包括 19 次插入11 次删除
  1. 二進制
      tutorials/inputs/img/inputs_inputmap.png
  2. 二進制
      tutorials/inputs/img/inputs_inputmap.webp
  3. 19 11
      tutorials/inputs/input_examples.rst

二進制
tutorials/inputs/img/inputs_inputmap.png


二進制
tutorials/inputs/img/inputs_inputmap.webp


+ 19 - 11
tutorials/inputs/input_examples.rst

@@ -101,13 +101,18 @@ event scroll by in the output window. Here's an example of the output:
 ::
 ::
 
 
     A
     A
-    InputEventMouseMotion : button_mask=0, position=(108, 108), relative=(26, 1), speed=(164.152496, 159.119843), pressure=(0), tilt=(0, 0)
-    InputEventMouseButton : button_index=MOUSE_BUTTON_LEFT, pressed=true, position=(108, 107), button_mask=1, doubleclick=false
-    InputEventMouseButton : button_index=MOUSE_BUTTON_LEFT, pressed=false, position=(108, 107), button_mask=0, doubleclick=false
-    S
-    F
+    Mouse motion at position ((971, 5)) with velocity ((0, 0))
+    Right Mouse Button
+    Mouse motion at position ((870, 243)) with velocity ((0.454937, -0.454937))
+    Left Mouse Button
+    Mouse Wheel Up
+    A
+    B
+    Shift
+    Alt+Shift
     Alt
     Alt
-    InputEventMouseMotion : button_mask=0, position=(108, 107), relative=(0, -1), speed=(164.152496, 159.119843), pressure=(0), tilt=(0, 0)
+    Shift+T
+    Mouse motion at position ((868, 242)) with velocity ((-2.134768, 2.134768))
 
 
 As you can see, the results are very different for the different types of
 As you can see, the results are very different for the different types of
 input. Key events are even printed as their key symbols. For example, let's
 input. Key events are even printed as their key symbols. For example, let's
@@ -150,11 +155,14 @@ InputMap
 The :ref:`InputMap <class_InputMap>` is the most flexible way to handle a
 The :ref:`InputMap <class_InputMap>` is the most flexible way to handle a
 variety of inputs. You use this by creating named input *actions*, to which
 variety of inputs. You use this by creating named input *actions*, to which
 you can assign any number of input events, such as keypresses or mouse clicks.
 you can assign any number of input events, such as keypresses or mouse clicks.
-A new Godot project includes a number of default actions already defined. To
-see them, and to add your own, open Project -> Project Settings and select
+To see them, and to add your own, open Project -> Project Settings and select
 the InputMap tab:
 the InputMap tab:
 
 
-.. image:: img/inputs_inputmap.png
+.. image:: img/inputs_inputmap.webp
+
+.. tip::
+    A new Godot project includes a number of default actions already defined.
+    To see them, turn on ``Show Built-in Actions`` in the InputMap dialog.
 
 
 Capturing actions
 Capturing actions
 ~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~
@@ -240,7 +248,7 @@ different when it's :kbd:`Shift + T`:
     func _input(event):
     func _input(event):
         if event is InputEventKey and event.pressed:
         if event is InputEventKey and event.pressed:
             if event.keycode == KEY_T:
             if event.keycode == KEY_T:
-                if event.shift:
+                if event.shift_pressed:
                     print("Shift+T was pressed")
                     print("Shift+T was pressed")
                 else:
                 else:
                     print("T was pressed")
                     print("T was pressed")
@@ -254,7 +262,7 @@ different when it's :kbd:`Shift + T`:
             switch (keyEvent.Keycode)
             switch (keyEvent.Keycode)
             {
             {
                 case Key.T:
                 case Key.T:
-                    GD.Print(keyEvent.Shift ? "Shift+T was pressed" : "T was pressed");
+                    GD.Print(keyEvent.ShiftPressed ? "Shift+T was pressed" : "T was pressed");
                     break;
                     break;
             }
             }
         }
         }