Skip to content

Commit

Permalink
fix(ROI): Avoid removing highlighting of ROI after closing ROI info d…
Browse files Browse the repository at this point in the history
…ialog and use double click to open it (#197)

* Avoid unselect closing or submitting roi dialog

* Add double click event

* Lint
  • Loading branch information
igoroctaviano authored May 8, 2024
1 parent 17e203f commit a76a79f
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/components/SlideViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,19 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
}
}

onRoiDoubleClicked = (event: CustomEventInit): void => {
const selectedRoi = event.detail.payload as dmv.roi.ROI
if (selectedRoi != null) {
this.setState({
isSelectedRoiModalVisible: true
})
} else {
this.setState({
isSelectedRoiModalVisible: false
})
}
}

onRoiSelected = (event: CustomEventInit): void => {
const selectedRoi = event.detail.payload as dmv.roi.ROI
if (selectedRoi != null) {
Expand All @@ -1430,22 +1443,19 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
})
this.setState({
selectedRoiUIDs: new Set([selectedRoi.uid]),
selectedRoi: selectedRoi,
isSelectedRoiModalVisible: true
selectedRoi: selectedRoi
})
} else {
this.setState({
selectedRoiUIDs: new Set(),
selectedRoi: undefined,
isSelectedRoiModalVisible: false
selectedRoi: undefined
})
}
}

handleRoiSelectionCancellation (): void {
this.setState({
isSelectedRoiModalVisible: false,
selectedRoiUIDs: new Set()
isSelectedRoiModalVisible: false
})
}

Expand Down Expand Up @@ -1566,6 +1576,10 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
'dicommicroscopyviewer_roi_selected',
this.onRoiSelected
)
document.body.removeEventListener(
'dicommicroscopyviewer_roi_double_clicked',
this.onRoiDoubleClicked
)
document.body.removeEventListener(
'dicommicroscopyviewer_roi_removed',
this.onRoiRemoved
Expand Down Expand Up @@ -1665,6 +1679,10 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
'dicommicroscopyviewer_roi_selected',
this.onRoiSelected
)
document.body.addEventListener(
'dicommicroscopyviewer_roi_double_clicked',
this.onRoiDoubleClicked
)
document.body.addEventListener(
'dicommicroscopyviewer_roi_removed',
this.onRoiRemoved
Expand Down

0 comments on commit a76a79f

Please sign in to comment.