Skip to main content

contextActionServiceUtil

A simple utility module for working with ContextActionService.

Functions

bindActionNoInputSink

contextActionServiceUtil.bindActionNoInputSink(
actionNamestring,
actionCallback(
actionNamestring,
inputStateEnum.UserInputState,
inputObjectInputObject
) → (),
createTouchButtonboolean,
...Enum.UserInputType | Enum.KeyCode
) → ()

Works almost exactly the same as ContextActionService:BindAction, except that a custom handler is passed as the 2nd argument, which then calls actionCallbackbut returns Enum.ContextActionResult.Pass so the handler never sinks any inputs.

You can think of the custom handler like this:

function(...)
	actionCallback(...)
	return Enum.ContextActionResult.Pass
end
contextActionServiceUtil.bindActionNoInputSink(
	"Input", 
	function(_, inputState: Enum.UserInputState, inputObject: InputObject)
		print("User pressed Enum.Keycode.A")
	end, 
	false, Enum.Keycode.A
)
Show raw api
{
    "functions": [
        {
            "name": "bindActionNoInputSink",
            "desc": "Works almost exactly the same as [ContextActionService:BindAction](https://create.roblox.com/docs/reference/engine/classes/ContextActionService#BindAction),\nexcept that a custom handler is passed as the 2nd argument, which then calls `actionCallback`but returns `Enum.ContextActionResult.Pass` so \nthe handler never sinks any inputs.\n\nYou can think of the custom handler like this:\n\n```lua\nfunction(...)\n\tactionCallback(...)\n\treturn Enum.ContextActionResult.Pass\nend\n```\n\n```lua\ncontextActionServiceUtil.bindActionNoInputSink(\n\t\"Input\", \n\tfunction(_, inputState: Enum.UserInputState, inputObject: InputObject)\n\t\tprint(\"User pressed Enum.Keycode.A\")\n\tend, \n\tfalse, Enum.Keycode.A\n)\n```",
            "params": [
                {
                    "name": "actionName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "actionCallback",
                    "desc": "",
                    "lua_type": "(\n\t\tactionName: string,\n\t\tinputState: Enum.UserInputState,\n\t\tinputObject: InputObject\n\t) -> ()"
                },
                {
                    "name": "createTouchButton",
                    "desc": "",
                    "lua_type": "boolean"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "Enum.UserInputType | Enum.KeyCode\n"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 35,
                "path": "src/contextActionServiceUtil/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "contextActionServiceUtil",
    "desc": " \n\nA simple utility module for working with [ContextActionService](https://create.roblox.com/docs/reference/engine/classes/ContextActionService).",
    "source": {
        "line": 6,
        "path": "src/contextActionServiceUtil/init.luau"
    }
}