Skip to content

Commit

Permalink
Add contextmenu support Control + Enter for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
kadiryazici committed Mar 17, 2024
1 parent ecfae0d commit 6e3bad9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/components/NotificationItem.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts" setup>
import { type as osType } from '@tauri-apps/api/os'
import type { MinimalRepository, Thread } from '../api/notifications'
import type { NotificationList } from '../types'
import { isRepository, isThread, notificationSubjectIcon } from '../utils/notification'
Expand Down Expand Up @@ -32,11 +33,30 @@ function isInteractedCheckbox(e: MouseEvent | KeyboardEvent) {
return e.target instanceof HTMLElement && e.target.closest('.notification-checkbox') != null
}
function handleThreadClick(thread: Thread, event: MouseEvent | KeyboardEvent) {
async function handleThreadClick(thread: Thread, event: MouseEvent | KeyboardEvent) {
if ((event instanceof KeyboardEvent && event.repeat)) {
return
}
const os = await osType()
if (os === 'Darwin' && event.ctrlKey) {
queueMicrotask(() => {
const el = event.target as HTMLElement
const bounds = el.getBoundingClientRect()
const [x, y] = [bounds.left + bounds.width / 2, bounds.top + bounds.height / 2]
el.dispatchEvent(new MouseEvent('contextmenu', {
bubbles: true,
cancelable: true,
screenX: x,
screenY: y,
clientX: x,
clientY: y,
}))
})
return
}
if (props.checkable && ((event.ctrlKey || event.metaKey) || isInteractedCheckbox(event))) {
emit('update:checked', !props.checked)
return
Expand Down

0 comments on commit 6e3bad9

Please sign in to comment.