Skip to content

New extension: OnPressDetector#527

Closed
github-actions[bot] wants to merge 1 commit intomainfrom
extension/Kapusta-dev/526
Closed

New extension: OnPressDetector#527
github-actions[bot] wants to merge 1 commit intomainfrom
extension/Kapusta-dev/526

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Aug 4, 2022

Description

This extension adds the ability to detect Mouse 'On Click' and Keyboard 'On Press' conditions, so that events will only run when the key/button were just pressed, rather than held down.

Useful so that holding down the mouse button and moving over a button does not trigger the button being activated.

How to use the extension

Put either the 'Detect Mouse On Click Event' or 'Detect Keyboard On Press Event' as conditions for any events that need to be triggered immediately on a mouse press / keyboard button click, and not trigger if mouse or keyboard buttons are being held thereafter.

For example, to make sure a button is only triggered when it is clicked and not when the mouse button is held down and dragged over it, create the following event:

Conditions:

  • Mouse Button Left 'OnClick' Detected
  • The cursor/touch is on 'Button'

Events:

  • Trigger any relevant button events

Checklist

  • I've followed all of the best practices.
  • I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.

What tier of review do you aim for your extension?

Reviewed

Example file

OnClickDetectorExample.zip

Extension file

OnPressDetector.zip

@github-actions github-actions bot requested a review from a team as a code owner August 4, 2022 19:41
@github-actions github-actions bot added the ✨ New extension A new extension label Aug 4, 2022
@github-actions github-actions bot mentioned this pull request Aug 4, 2022
3 tasks
@D8H D8H added the 🔍 Reviewed extension An extension that is to be reviewed in great detail before merging. label Aug 6, 2022
@VegeTato
Copy link
Contributor

VegeTato commented Aug 9, 2022

Hello @Kapusta-dev 👋
that's a cool extension :)
i noticed few things in the extension that require a lil fix:

• Rather than using timers, you can use a better and stable way, which is (Boolean variable)
here is an edited events of your example showing how to do it :
11111

• Short description should be shorter than what you have currently.

• Long description shouldn't have the same short description sentence, unless you want that.

Honestly, the extension can be done using a Boolean variable as i showed above, so currently its very basic and simple and unlikely to get merged into GDevelop Reviewed extensions, But it can be added in the community extensions if you still want it in :3

Thanks for submitting the extension 💖 would love to see more extensions from you as well 😉

@Kapusta-dev
Copy link

Kapusta-dev commented Aug 10, 2022

Hey @VegeTato
Thanks for the information! I'll have to edit the short and long descriptions per your suggestions.

The button example provided was just a quick way to demonstrate the ease of use for the extension, and a situation where it would come in handy.
Here is another example, where the boolean method isn't so straightforward / easy to implement:
image

With the existing mouse events it will cycle through all the colors at once. With this extension it will cycle through each color per click.

As I'm using my extension more though I'm finding a few gotchas here and there (i.e. in certain cases the event must be called/exist on event where the parent is not shared, otherwise it does not run the mouse release timer. It must also be the first condition in the block) so perhaps it's not suited yet to be added officially and definitely needs some more work on it.

I'll have to keep poking at it - I think GDevelop would definitely benefit from an easy and straightforward 'mouse on click' event.

Thanks again!

@D8H
Copy link
Contributor

D8H commented Aug 10, 2022

Thank you for submitting an extension.

Do you know about this other submission?

I think it may answer the same kind of issues.

@Kapusta-dev
Copy link

Kapusta-dev commented Aug 10, 2022

Thanks D8H, that's a great extension and definitely solves the issue for buttons.

Per my second example in the comment above the goal for the extension was to also solve general mouse 'on click' detection for instances where you're not interacting with a button directly. I'll edit the description to reflect that, I think I focused too much on the button example. :)

@D8H
Copy link
Contributor

D8H commented Aug 10, 2022

ok, I guess the logic would be very similar to the "Double-click" extension. It could be interesting to see if they used the same logic.

I can't think of any UI that does something different for a mouse button release and a pressed + release in a short amount of time.
Can you give some examples?

@Kapusta-dev
Copy link

Quickly looked at the double click extension and it does seem like they use timers for the delay between clicks, and variables to count the number of clicks within the 'max delay' time.

This extension wouldn't necessarily have to be for UI, I'd apply it to any instance where I want something to happen when the user clicks the mouse, and not wait for the release to happen. Holding the mouse would evaluate to 'true' too many times.

Here is a simple state machine example:
image

This immediately jumps to green no matter which order you put the events in.
I could re-structure it so to achieve the desired outcome:
image

But that's not optimal when you're trying to keep track of states over a large project. I'd want the conditions to be under each state.

Here is the same first block with the extension:
image

Each click goes through the states, first changing to red, and then on the second click changing to green. Still not ideal because you have to order the events in reverse, else they will all trigger, but hopefully gets the idea across.

I personally used this extension to create a visual novel game for the latest GDevelop game jam. I was using the boolean method that VegeTato described to keep track of mouse clicks and only advance text on the first click (So if they hold the mouse button down it won't just keep advancing the text, they would have to click again) but that was a bit cumbersome having to check for the boolean every time I have a mouse click condition, therefore I created this extension and thought it might be useful for others.

As mentioned though, there's a lot of edge cases with it right now, so I wouldn't want it added officially just yet, I'll need to keep working on it, or hopefully an official implementation at some point. Not sure what the rules are for mentioning other engines, but there are a few that have 'on-click' conditions which comes in handy a lot.

@D8H
Copy link
Contributor

D8H commented Aug 10, 2022

As mentioned though, there's a lot of edge cases with it right now, so I wouldn't want it added officially just yet, I'll need to keep working on it, or hopefully an official implementation at some point.

ok

Not sure what the rules are for mentioning other engines, but there are a few that have 'on-click' conditions which comes in handy a lot.

No engine is Voldemort here. You can speak freely of Construct, ClickTeam, Godot or anything else 😄

@arthuro555
Copy link
Member

This PR is looking dead, I'll close it, feel free to reopen if someone's getting back to it

@arthuro555 arthuro555 closed this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ New extension A new extension 🔍 Reviewed extension An extension that is to be reviewed in great detail before merging.

Projects

Status: Rejected

Development

Successfully merging this pull request may close these issues.

4 participants