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

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

Thank you very much @Automate_MyProject

Maybe, but you don't know other's needs :wink:

1 Like

Ok ok ok I will return id and component both.

UPDATE -

Here is the new version of extension :partying_face:

Changes

component_event (3)

component_method (2)
Now it returns the component instead of id
Thanks to @WatermelonIce for suggestion

New blocks

component_method (3)
component ~ component
It performs click of component without clicking that component. It can be done using procedures also still I thought to add it to extension.

component_event (4)
Now it is possible to do long click of component.

New AIX

in.vedang.clicktool.aix (8.4 KB)

2 Likes

But sadly no unRegister method....

1 Like

Sorry for that :sob: will be added

I wanted to ask, why does anyone want to register an already clickable object? But the new longclick option make sense.

@Techno_Vedang, very useful extension. Thank you!

1 Like

@Zol you are wrong. We don't know how others will use the extension so clarifying all things is always correct.

Thank you very much :smiling_face_with_three_hearts: :upside_down_face:

More suggestions: Add the touchup and touchdown event :wink:

It is the View.OnTouchListener

1 Like

sure but tomorrow

2 Likes

Great extension :+1: :+1:

Is it similar to this :point_down:

They are clickable by default as I think.

3 Likes

Thank you very much :star_struck:

i think so :innocent:

I think they are not clickable until we put a on click listener on it :grin:

Hmmm... Listener is different from clickable.

2 Likes

Actually you can controll if they are clickable or not using setClickable method, it's by default, set to true, but if it got set to false, neither the native click event nor the extension can detect touches on.
BTW, after the update only the long click event works, the click event doesn't work.

2 Likes

Then @Techno_Vedang might need to make an urgent update again as soon as possible :sweat_smile:

In Kodular it is, but I'm not sure about AI2

1 Like

Let me test it now with setClickable method in AI2 :wink:

BTW, you can add a separate block for registering long click , i think that should solve it.

2 Likes

both are not possible in one block?

1 Like