Multiple Element Selection in Javascripted UI far from easy - ΩJr. Software Articles and Products

This information lives on a web page hosted at the following web address: 'https://omegajunior.globat.com/code/'.

Allowing a web app user to select multiple items on screen (like objects in a game or drawing app) proves harder than it seems. An exploration.

A.E.Veltstra
Sunday, October 25, 2009

For my Canvas Composition Studio over at Pantheon Online Games, the very first of its kind on the internet, I decided to implement multi-select. I wanted to allow a user to select more than one composition items and treat them at the same time. Boy was I in for a surprise.

I chose to model the multi-select partially after the way MS Windows Explorer allows file selection. That would allow a user to grab an item and start moving it immediately, but also ctrl-click to add to or remove from the selection of items, and those two combined.



Visual of multi-select functionality

Sounds easy?

Think again. The decision tree for this should be taught at UI programming courses (and it may already be... I never got it in mine).

Not only that... try it in javascript, and find out that some web browser fires events differently from others. Choose your events wisely.

Finally, as the test in my previous post shows, for some awkward reason I incorrectly assumed that changing any html attribute apart from class, would actually cause browsers to apply different CSS styles (just like when changing class). None of them do. I checked... and as it turns out, the latest HTML 4 version (one that is not yet a recommendation) does advise exactly that behaviour.

So I had to add a class changer. Purely silly, if you ask me. However, I did manage to get it done.

Thus, functionality added or changed:


Known issues:


Next on the list: add more clip-art.

Go give it a try. Please report back any problems you find.

Need problem solving?

Talk to me. Let's meet for coffee or over lunch. Mail me at “omegajunior at protonmail dot com”.