ClickTools - An Extension To Add Click Events To Arrangements And View Components

By using this extension you will be able to add Click Events to app inventor components and layouts

Blocks

b


Documentation -

component_method (1)
component ~ component
id ~ int (number)


component_event (2)
id ~ id you used for your registered component
Use this event to set blocks of component click.


component_event (1)
error ~ It returns the error if something went wrong
Use this event to do something after error occured


:warning: :warning: IMPORTANT :warning: :warning:
If you register button or another clickable components then the built in .Click event will not work
See here


Download Link

DOWNLOAD EXTENSION

16 Likes

Nice extension vedang! I think you need to remove On in events blocks because it does not match

When OnComponentClick. Just a suggestion :slightly_smiling_face:

2 Likes

Yess you are correct I will do it :upside_down_face:

1 Like

This is really an overdue extension. Thanks.

3 Likes

Maybe you could / should add an .Unregister method so that clicks on the respective components can also be disabled (comparable to Button.Enabled to false).

2 Likes

Yeah it's a good idea. I will add it in next update

Wow! Amazing extension!

1 Like

Wow, that's a really useful extension :heart_eyes:

1 Like

Thank you very much @Anke @Mayank_Kumar @Salman_Dev @Kumaraswamy :heart_eyes:

You should also mention in the documentation that if a component has been registered, the original .Click event (e.g. Button.Click) will no longer be executed.

grafik

1 Like

Ok. I will create a documentation and mentions this :upside_down_face:

1 Like

Will the Click event be triggered if the component isn't clickable?

1 Like

Yes because in app inventor labels and arrangements are also not clickable but it works

Great! :+1:

1 Like

Hey, did you know that your extension makes AI2 components similar to those in Kodular because they already have .Click event for Non-Button Components, SO it means that your extension makes App Inventor better than it already is. AND sorry for posting twice to say the same thing again.

1 Like

Thank you very much @WatermelonIce

Thanks for your appreciation @Mayank_Kumar Your words are motivating me alot

1 Like

I recommend to return a component in the event. The code will like something like this:

@SimpleEvent(description = "Rasies when clicked")

    public void Clicked(final AndroidViewComponent component) {

        EventDispatcher.dispatchEvent(this, "Clicked", component);

    }

@SimpleFunction(description = "Register")

    public void RegisterOnClick(final AndroidViewComponent component) {

        component.getView().setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                Clicked(component);

            }

        });

    }
3 Likes

@Techno_Vedang, It is an excellent extension. Now the user has the choice to add Click event to his components. Thank you very much for your contribution.

1 Like

I did it earlier but removed i thought id is enough