Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added shift select for amino acids, added copy feature for AA #247

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/EventHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ export class EventHandler extends React.PureComponent<EventsHandlerProps> {
*/
handleMouseEvent = (e: React.MouseEvent<HTMLDivElement>) => {
const { handleMouseEvent } = this.props;

if (e.shiftKey) {
this.handleCopy();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this bit, why does it copy every time the cursor moves when shift selecting? I feel like I'd never expect that + doesn't cmd + c work just as well? I also find it surprising to click a single amino acid but have the entire translation copied

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea this wasn't the best implementation for copying the highlighted aa sequence. For some reason a normal cmd + c doesn't work with a highlighted aa sequence (selecting using the click + shift method, not drag select). I tried a work around but for now I'm going to remove that

}
if (e.type === "mouseup") {
this.resetClicked();
if (this.clickedOnce === e.target && this.clickedTwice === e.target) {
Expand Down
14 changes: 13 additions & 1 deletion src/SelectionHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class SelectionHandler extends React.PureComponent<SelectionHandl
declare context: React.ContextType<typeof SelectionContext>;

/** Only state is the selection range */
state = { ...defaultSelection };
state = { ...defaultSelection, aminoAcidShiftStart: null };

/* previous base cursor is over, used in circular drag select */
previousBase: null | number = null;
Expand Down Expand Up @@ -173,6 +173,16 @@ export default class SelectionHandler extends React.PureComponent<SelectionHandl
selectionEnd = clockwise ? knownRange.end : knownRange.start;
}

if (e.shiftKey) {
if (this.state.aminoAcidShiftStart) {
selectionStart = this.state.aminoAcidShiftStart;
} else {
this.setState({ aminoAcidShiftStart: selectionStart });
}
} else {
this.setState({ aminoAcidShiftStart: null });
}

this.setSelection({
...knownRange,
clockwise: clockwise,
Expand All @@ -194,6 +204,8 @@ export default class SelectionHandler extends React.PureComponent<SelectionHandl
this.handleCircularSeqEvent(e);
}

this.setState({ aminoAcidShiftStart: null });

break;
}
default:
Expand Down