Browse Source

lovr.system.wasMousePressed/Released;

bjorn 10 months ago
parent
commit
e6725a1071
3 changed files with 140 additions and 0 deletions
  1. 66 0
      api/init.lua
  2. 37 0
      api/lovr/system/wasMousePressed.lua
  3. 37 0
      api/lovr/system/wasMouseReleased.lua

+ 66 - 0
api/init.lua

@@ -44281,6 +44281,72 @@ return {
               }
               }
             }
             }
           }
           }
+        },
+        {
+          name = "wasMousePressed",
+          tag = "system-mouse",
+          summary = "Check if a mouse button was pressed this frame.",
+          description = "Returns whether a button on the mouse was pressed this frame.",
+          key = "lovr.system.wasMousePressed",
+          module = "lovr.system",
+          notes = "Technically this returns whether the button was pressed between the last 2 calls to `lovr.system.pollEvents`, but that function is called automatically at the beginning of each frame in `lovr.run`, so it all works out!",
+          related = {
+            "lovr.system.isMouseDown",
+            "lovr.system.wasMouseReleased",
+            "lovr.mousepressed",
+            "lovr.mousereleased"
+          },
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "button",
+                  type = "number",
+                  description = "The index of a button to check.  Use 1 for the primary mouse button, 2 for the secondary button, and 3 for the middle button.  Other indices can be used, but are hardware-specific."
+                }
+              },
+              returns = {
+                {
+                  name = "pressed",
+                  type = "boolean",
+                  description = "Whether the mouse button was pressed this frame."
+                }
+              }
+            }
+          }
+        },
+        {
+          name = "wasMouseReleased",
+          tag = "system-mouse",
+          summary = "Check if a mouse button was released this frame.",
+          description = "Returns whether a button on the mouse was released this frame.",
+          key = "lovr.system.wasMouseReleased",
+          module = "lovr.system",
+          notes = "Technically this returns whether the button was released between the last 2 calls to `lovr.system.pollEvents`, but that function is called automatically at the beginning of each frame in `lovr.run`, so it all works out!",
+          related = {
+            "lovr.system.isMouseDown",
+            "lovr.system.wasMousePressed",
+            "lovr.mousepressed",
+            "lovr.mousereleased"
+          },
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "button",
+                  type = "number",
+                  description = "The index of a button to check.  Use 1 for the primary mouse button, 2 for the secondary button, and 3 for the middle button.  Other indices can be used, but are hardware-specific."
+                }
+              },
+              returns = {
+                {
+                  name = "released",
+                  type = "boolean",
+                  description = "Whether the mouse button was released this frame."
+                }
+              }
+            }
+          }
         }
         }
       },
       },
       objects = {},
       objects = {},

+ 37 - 0
api/lovr/system/wasMousePressed.lua

@@ -0,0 +1,37 @@
+return {
+  tag = 'system-mouse',
+  summary = 'Check if a mouse button was pressed this frame.',
+  description = 'Returns whether a button on the mouse was pressed this frame.',
+  arguments = {
+    button = {
+      type = 'number',
+      description = [[
+        The index of a button to check.  Use 1 for the primary mouse button, 2 for the secondary
+        button, and 3 for the middle button.  Other indices can be used, but are hardware-specific.
+      ]]
+    }
+  },
+  returns = {
+    pressed = {
+      type = 'boolean',
+      description = 'Whether the mouse button was pressed this frame.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'button' },
+      returns = { 'pressed' }
+    }
+  },
+  notes = [[
+    Technically this returns whether the button was pressed between the last 2 calls to
+    `lovr.system.pollEvents`, but that function is called automatically at the beginning of each
+    frame in `lovr.run`, so it all works out!
+  ]],
+  related = {
+    'lovr.system.isMouseDown',
+    'lovr.system.wasMouseReleased',
+    'lovr.mousepressed',
+    'lovr.mousereleased'
+  }
+}

+ 37 - 0
api/lovr/system/wasMouseReleased.lua

@@ -0,0 +1,37 @@
+return {
+  tag = 'system-mouse',
+  summary = 'Check if a mouse button was released this frame.',
+  description = 'Returns whether a button on the mouse was released this frame.',
+  arguments = {
+    button = {
+      type = 'number',
+      description = [[
+        The index of a button to check.  Use 1 for the primary mouse button, 2 for the secondary
+        button, and 3 for the middle button.  Other indices can be used, but are hardware-specific.
+      ]]
+    }
+  },
+  returns = {
+    released = {
+      type = 'boolean',
+      description = 'Whether the mouse button was released this frame.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'button' },
+      returns = { 'released' }
+    }
+  },
+  notes = [[
+    Technically this returns whether the button was released between the last 2 calls to
+    `lovr.system.pollEvents`, but that function is called automatically at the beginning of each
+    frame in `lovr.run`, so it all works out!
+  ]],
+  related = {
+    'lovr.system.isMouseDown',
+    'lovr.system.wasMousePressed',
+    'lovr.mousepressed',
+    'lovr.mousereleased'
+  }
+}