# Possible to bound an action to a region?

**URL:** <https://forum.defold.com/t/possible-to-bound-an-action-to-a-region/71858>\
**Category:** Questions\
**Created:** [October 13, 2022, 6:39am UTC](https://forum.defold.com/t/possible-to-bound-an-action-to-a-region/71858 "2022-10-13T06:39:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bingo\_Boy](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/bingo_boy/32/27695_2.png) [@Bingo\_Boy](https://forum.defold.com/u/Bingo_Boy)\
**Post date:** [October 13, 2022, 6:39am UTC](https://forum.defold.com/t/possible-to-bound-an-action-to-a-region/71858/1 "2022-10-13T06:39:26Z")

</div>

I was wondering if it is possible to make it so an action only happens if it is performed in a given location. For example I want an action to be performed on a mouse click but only when the mouse click is in a square, bound by x and y coordinates. Is this possible? How would I do it?

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [October 13, 2022, 7:19am UTC](https://forum.defold.com/t/possible-to-bound-an-action-to-a-region/71858/2 "2022-10-13T07:19:54Z")

</div>

Certainly possible, there are all kinds of ways to achieve it. Here is a very simple example.

```lua
	if action.released and action_id == hash("touch") then
		if action.x > 0 and action.x < 100 and action.y > 0 and action.y < 100 then
			--do stuff
		end
	end

```

For GUI, I recommend you read up on [gui.pick\_node()](https://defold.com/ref/gui/#gui.pick_node:node-x-y).

See [this thread](https://forum.defold.com/t/what-is-the-difference-between-action-xy-and-action-screen-xy-solved/68711) to understand the different types of coordinates returned in an input action.

---

<div class="post-metadata">

**Author:** ![Ivan\_Lytkin](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ivan_lytkin/32/2654_2.png) [@Ivan\_Lytkin](https://forum.defold.com/u/Ivan_Lytkin)\
**Post date:** [October 13, 2022, 7:31am UTC](https://forum.defold.com/t/possible-to-bound-an-action-to-a-region/71858/3 "2022-10-13T07:31:18Z")

</div>

Another approach is to use trigger collision objects and put small collision object at place of mouse click to get trigger\_response message.
