Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Calendar: Ctrl+Option+arrows move the open event — 15 minutes or a week up and down, a day left and right — as on a Mac

Yashwanth Kamireddi5eeefab9ea7f
diff --git a/.uiverify/calendar-keys.mjs b/.uiverify/calendar-keys.mjs
index fe2e8df..3f573e2 100644
--- a/.uiverify/calendar-keys.mjs
+++ b/.uiverify/calendar-keys.mjs
@@ -25,5 +25,18 @@ await page.waitForTimeout(200);
await page.keyboard.press("Control+n");
await page.waitForTimeout(400);
ok(await page.locator(".cx-block.is-draft").count() === 1, "Ctrl+N starts a new event");
+// Control-Option-Down moves the open event fifteen minutes later, and saves it.
+await page.keyboard.press("Escape");
+await page.waitForTimeout(200);
+await page.evaluate(() => { window.__nudges = []; const t = window.__TAURI_INTERNALS__; const inner = t.invoke;
+ t.invoke = async (c, a) => { if (c === "event_save") window.__nudges.push(a.draft); return inner(c, a); }; });
+await page.locator(".cx-block", { hasText: "Design review" }).first().click();
+await page.waitForTimeout(250);
+await page.evaluate(() => document.activeElement?.blur());
+await page.keyboard.press("Control+Alt+ArrowDown");
+await page.waitForTimeout(300);
+const sent = await page.evaluate(() => window.__nudges);
+ok(sent.length === 1 && sent[0].guid === "e1" && (sent[0].startsAt % 3600) === 900,
+ `Ctrl+Option+Down moves the event 15 minutes later ${JSON.stringify(sent.map((d) => d.startsAt % 3600))}`);
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index 88ab450..9377ee7 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -704,6 +704,13 @@ export function CalendarView() {
if (await save(draft)) setDraft(null);
}}
onDelete={draft.guid ? () => void remove(draft.guid as string) : undefined}
+ onNudge={draft.guid ? (by) => {
+ // Calendar's Control-Option-arrows: the open event moves, stays open, and is saved.
+ const moved = { ...draft, startsAt: draft.startsAt + by, endsAt: draft.endsAt + by };
+ setDraft(moved);
+ void save(moved);
+ } : undefined}
+ view={view}
/>
)}
@@ -1503,6 +1510,8 @@ function EventPopover({
onClose,
onSave,
onDelete,
+ onNudge,
+ view,
}: {
draft: Draft;
at: Anchor;
@@ -1512,6 +1521,8 @@ function EventPopover({
onClose: () => void;
onSave: () => void;
onDelete?: () => void;
+ onNudge?: (bySeconds: number) => void;
+ view?: string;
}) {
const box = useRef<HTMLFormElement | null>(null);
const [pos, setPos] = useState<{ left: number; top: number }>({ left: at.x, top: at.y });
@@ -1537,6 +1548,16 @@ function EventPopover({
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") return onClose();
+ // Up/Down: fifteen minutes in Day and Week, a week in Month. Left/Right: a day.
+ if (e.ctrlKey && e.altKey && onNudge && editable && e.key.startsWith("Arrow")) {
+ const step = view === "month" || draft.allDay ? 7 * 86_400 : 15 * 60;
+ const by = { ArrowUp: -step, ArrowDown: step, ArrowLeft: -86_400, ArrowRight: 86_400 }[e.key];
+ if (by) {
+ e.preventDefault();
+ onNudge(by);
+ }
+ return;
+ }
// Delete, as in Calendar: an open event goes when Delete is pressed outside its fields —
// and Undo brings it back, since iCloud keeps no bin.
const typing = (e.target as HTMLElement | null)?.closest("input, textarea, select, [contenteditable]");
@@ -1554,7 +1575,7 @@ function EventPopover({
window.removeEventListener("keydown", onKey);
window.removeEventListener("mousedown", onDown);
};
- }, [onClose, onDelete, editable]);
+ }, [onClose, onDelete, onNudge, editable, view, draft.allDay]);
const set = (patch: Partial<Draft>) => onChange({ ...draft, ...patch });