Adding selection support

The multiple commits are caused by me uploading code via Github. I will rebase it all before I merge. 
I actually couldn’t figure out what you want to achieve with the code beginning at line 71 and ending at line 109.