Support metaKey and ctrlKey for selection.

MetaKey is the windows key on Windows/Linux. Using only that for
selecting items is really confusing, because AFAIK no existing
application does that. With this commit, ctrl can be used for selecting
items as well.
This commit is contained in:
Nils Asmussen 2016-08-28 16:15:15 +02:00
parent 425749eb85
commit a765b5ee06

View File

@ -3,6 +3,12 @@
* @copyright 2015 by Tobias Reich * @copyright 2015 by Tobias Reich
*/ */
const isSelectKeyPressed = function(e) {
return e.metaKey || e.ctrlKey
}
multiselect = { multiselect = {
ids: [] ids: []
@ -71,8 +77,8 @@ multiselect.albumClick = function(e, albumObj) {
let id = albumObj.attr('data-id') let id = albumObj.attr('data-id')
if (e.metaKey===true) multiselect.toggleItem(albumObj, id) if (isSelectKeyPressed(e)) multiselect.toggleItem(albumObj, id)
else lychee.goto(id) else lychee.goto(id)
} }
@ -80,8 +86,8 @@ multiselect.photoClick = function(e, photoObj) {
let id = photoObj.attr('data-id') let id = photoObj.attr('data-id')
if (e.metaKey===true) multiselect.toggleItem(photoObj, id) if (isSelectKeyPressed(e)) multiselect.toggleItem(photoObj, id)
else lychee.goto(album.getID() + '/' + id) else lychee.goto(album.getID() + '/' + id)
} }
@ -251,7 +257,7 @@ multiselect.getSelection = function(e) {
if (visible.contextMenu()) return false if (visible.contextMenu()) return false
if (!visible.multiselect()) return false if (!visible.multiselect()) return false
if (e.metaKey===false && (size.width==0 || size.height==0)) { if (!isSelectKeyPressed(e) && (size.width==0 || size.height==0)) {
multiselect.close() multiselect.close()
return false return false
} }