Handle context menu events in header cells
This commit is contained in:
parent
9579c9c0d2
commit
f516011182
|
@ -18,14 +18,23 @@
|
||||||
$: canMoveLeft = orderable && column.idx > 0
|
$: canMoveLeft = orderable && column.idx > 0
|
||||||
$: canMoveRight = orderable && column.idx < $columns.length - 1
|
$: canMoveRight = orderable && column.idx < $columns.length - 1
|
||||||
|
|
||||||
const startReordering = e => {
|
const onMouseDown = e => {
|
||||||
timeout = setTimeout(() => {
|
if (e.button === 0 && orderable) {
|
||||||
reorder.actions.startReordering(column.name, e)
|
timeout = setTimeout(() => {
|
||||||
}, 200)
|
reorder.actions.startReordering(column.name, e)
|
||||||
|
}, 200)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopReordering = () => {
|
const onMouseUp = e => {
|
||||||
clearTimeout(timeout)
|
if (e.button === 0 && orderable) {
|
||||||
|
clearTimeout(timeout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onContextMenu = e => {
|
||||||
|
e.preventDefault()
|
||||||
|
open = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortAscending = () => {
|
const sortAscending = () => {
|
||||||
|
@ -66,8 +75,9 @@
|
||||||
<SheetCell
|
<SheetCell
|
||||||
reorderSource={$reorder.sourceColumn === column.name}
|
reorderSource={$reorder.sourceColumn === column.name}
|
||||||
reorderTarget={$reorder.targetColumn === column.name}
|
reorderTarget={$reorder.targetColumn === column.name}
|
||||||
on:mousedown={orderable ? startReordering : null}
|
on:mousedown={onMouseDown}
|
||||||
on:mouseup={orderable ? stopReordering : null}
|
on:mouseup={onMouseUp}
|
||||||
|
on:contextmenu={onContextMenu}
|
||||||
width={column.width}
|
width={column.width}
|
||||||
left={column.left}
|
left={column.left}
|
||||||
>
|
>
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
on:mousedown
|
on:mousedown
|
||||||
on:mouseup
|
on:mouseup
|
||||||
on:click
|
on:click
|
||||||
|
on:contextmenu
|
||||||
{style}
|
{style}
|
||||||
data-row={rowIdx}
|
data-row={rowIdx}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue