Adding more than one click event to a button

If a click event is added to a button for example, ‘click’ is no longer an option if you want to add a second event to the same button. So if you want to trigger different events using modifier keys, eg you can’t do this:

image

(unless you edit the code manually). Not a big problem, but I wouldn’t have thought the option of a second click should be removed.

Why not just add more actions to the first on click event? You aren’t limited to one action per event like in Dreamweaver.

I realise you can add multiple actions to one event (it would be difficult to imagine using Wappler without this option - in this case, each of the clicks has multiple actions attached).

However as far as I can see, you can only specify modifier keys with the event, not when you define the actions.

Ah! I see what you are saying now. I can indeed see this being an issue.

why not do as i did it.
add more than one button and play with show and hide to fit your need

Yes, this is what I do if I have what looks like one button to turn something on or off (or add/remove etc.) - but it’s actually two buttons with show/hide conditions.

The modifier keys is a different issue - I only want one button.

I think in this case he wants one button that does something on regular click and another action based on Shift/Click on the same button. Can’t see how showing or hiding will accomplish this.

he doesn’t want to use the modifier in the first place as i understand.
but how do you (logically) want the same button to do different things?

I could see a few use cases for this that I never thought of before that I may even use in my next dashboard.

COuld have a form button that on click updates a record and on Shift/Click deletes the record. This is just one example.

i knew about them but they are not that useful on mobile :sweat_smile:

I think perhaps I wasn’t very clear. I’ve got the feature to work exacly as I want - it’s just that I had to edit the code because Wappler assumed (like you) that I would not/should not want to use the same button for different things. This assumption is not correct; I often want the same button to do different things (not just when developing with Wappler).

In this case I have a button which adds or deletes IDs to/from a cookie (using the show/hide technique you mention). The user may want to delete all IDs from the cookies - in this case to delete all the items s/he’s selected. I don’t want to this to be too easy (because in most cases deleting individual items will be sufficient). However, it could be a useful option. So, if the delete button is showing, holding the shift key while clicking it will delete all of the items (without a dialog popping up).

1 Like

True, but this is a useful feature, not a critical one. As Brad mentions, it could be useful for dashboard/admin sections. Eg I would probably never have a ‘delete’ button that simply deleted a record; I would show some sort of warning/dialog. However if the user wants to delete 20 records, one at a time, it’s very irritating to dismiss 20 dialog boxes. Using modifier keys is a good method to resolve this, and easily handled in Wappler (but could be a little easier if the issue I brought up is addressed).

1 Like

In the app connect framework you can only have one click even without modifiers and more with unique modifiers settings.

So this means you can have like one click, one click with ctrl, other with shift etc as long as the combination is unique.

If you want multiple actions you can add them to a single click event indeed.

As for doing different things with the same button ( even if extra ctrl is involved) I would strongly advice against it. This can be very confusing to the end users.

Just make different buttons, with different colors and clear action text on them and show / hide the one appropriate.

I’m not sure what you mean. This is what I’ve used - I have a click without modifiers and a click with modifiers. (You certainly can do this using Wappler/App Connect framework, you just have to do it partly in code view.)

To have two different buttons - one to click without a modifier key and the other to click with a modifier key would (in my opinion) be more confusing than having one button for both purposes.

Having said that, I would very rarely use modifier keys on a website. Many people are confused by modifier keys - and shortcut keys - generally. However for people who use such features, they know they can save a lot of time. Eg in Wappler: selecting adjacent (or non-adjacent) files in File Manager, or fields in Query builder or using multiple cursors in code view etc…

I’m thinking more for what is in effect an application (which Wappler is very capable of creating). I think modifier keys are a very useful feature - as in my example of deleting records. There are situations when I don’t want things to be very obvious or easy. I don’t think I would ever create two buttons in relation to modifier keys (I don’t see why you would use modifier keys at all in that case).