unclecheese / react-selectable

A component for react that allows mouse selection of child items
MIT License
142 stars 72 forks source link

Ability to specify modifier key to activate select - feature request #46

Closed avroshk closed 7 years ago

avroshk commented 7 years ago

I love this component. I have been using it for every list I make.

I needed a way to allow select only when a modifier key is pressed. I am not sure how desirable it might be for everyone but if so, it will be cool to include it as a prop option we can choose to provide.

https://github.com/unclecheese/react-selectable/blob/master/src/selectable-group.js#L155

/*  selectable-group.js */
if (e.metaKey) { 
    window.addEventListener('mousemove', this._openSelector);
}
unclecheese commented 7 years ago

Hey, thanks for the kind words. I think what you're looking for is the enabled prop. Just attach an event handler to your window that toggles that prop when a certain key is pressed.

avroshk commented 7 years ago

Thanks. That's much better.