Skip to content

Commit 5f080a8

Browse files
committed
use native clipboard on macos
On macOS we need the native Edit menu to make all keyboard shortcuts accessable. The shortcuts can copy/cut/paste text and nodes. But using entries from the menu itself only interacts with text. Therefore on macOS a new menu is added: "Nodes" Menu structure: *Nodes | |- Undo |- Redo |-------- |- Cut |- Copy |- Paste |-------- |- Duplicate |- Duplicate with Connections This menus sole purpose is to give the user a menu to interact with Nodes. closes #958 #1590
1 parent 0e6191d commit 5f080a8

File tree

4 files changed

+136
-119
lines changed

4 files changed

+136
-119
lines changed

backend/src/nodes/impl/clipboard/__init__.py

-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
from .clipboard_linux import LinuxClipboard
2222

2323
DEFAULT_CLIPBOARD = LinuxClipboard()
24-
elif sys.platform == "darwin":
25-
from .clipboard_darwin import DarwinClipboard
2624

27-
DEFAULT_CLIPBOARD = DarwinClipboard()
2825
else:
2926
raise NotImplementedError("No suitable clipboard found.")
3027
except Exception as e:

backend/src/nodes/impl/clipboard/clipboard_darwin.py

-35
This file was deleted.

backend/src/packages/chaiNNer_standard/__init__.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from sanic.log import logger
22

33
from api import KB, MB, Dependency, add_package
4-
from system import is_arm_mac, is_windows
4+
from system import is_windows
55

66
package = add_package(
77
__file__,
@@ -76,16 +76,7 @@
7676
],
7777
)
7878

79-
if is_arm_mac:
80-
package.add_dependency(
81-
Dependency(
82-
display_name="Pasteboard",
83-
pypi_name="pasteboard",
84-
version="0.3.3",
85-
size_estimate=19 * KB,
86-
)
87-
)
88-
elif is_windows:
79+
if is_windows:
8980
package.add_dependency(
9081
Dependency(
9182
display_name="Pywin32",

src/main/gui/menu.ts

+134-70
Original file line numberDiff line numberDiff line change
@@ -135,76 +135,140 @@ export const setMainMenu = ({ mainWindow, menuData, enabled = false }: MainMenuA
135135
isMac ? { role: 'close', enabled } : { role: 'quit', enabled },
136136
],
137137
},
138-
{
139-
label: 'Edit',
140-
submenu: [
141-
{
142-
label: 'Undo',
143-
accelerator: 'CmdOrCtrl+Z',
144-
registerAccelerator: false,
145-
click: () => {
146-
mainWindow.webContents.send('history-undo');
147-
},
148-
enabled,
149-
},
150-
{
151-
label: 'Redo',
152-
accelerator: 'CmdOrCtrl+Y',
153-
registerAccelerator: false,
154-
click: () => {
155-
mainWindow.webContents.send('history-redo');
156-
},
157-
enabled,
158-
},
159-
{ type: 'separator' },
160-
{
161-
label: 'Cut',
162-
accelerator: 'CmdOrCtrl+X',
163-
registerAccelerator: false,
164-
click: () => {
165-
mainWindow.webContents.send('cut');
166-
},
167-
enabled,
168-
},
169-
{
170-
label: 'Copy',
171-
accelerator: 'CmdOrCtrl+C',
172-
registerAccelerator: false,
173-
click: () => {
174-
mainWindow.webContents.send('copy');
175-
},
176-
enabled,
177-
},
178-
{
179-
label: 'Paste',
180-
accelerator: 'CmdOrCtrl+V',
181-
registerAccelerator: false,
182-
click: () => {
183-
mainWindow.webContents.send('paste');
184-
},
185-
enabled,
186-
},
187-
{ type: 'separator' },
188-
{
189-
label: 'Duplicate',
190-
accelerator: 'CmdOrCtrl+D',
191-
registerAccelerator: false,
192-
click: () => {
193-
mainWindow.webContents.send('duplicate');
194-
},
195-
enabled,
196-
},
197-
{
198-
label: 'Duplicate with Connections',
199-
accelerator: 'CmdOrCtrl+Shift+D',
200-
registerAccelerator: false,
201-
click: () => {
202-
mainWindow.webContents.send('duplicate-with-input-edges');
203-
},
204-
enabled,
205-
},
206-
],
207-
},
138+
...(isMac
139+
? [
140+
{ role: 'editMenu' },
141+
{
142+
label: 'Nodes',
143+
submenu: [
144+
{
145+
label: 'Undo',
146+
click: () => {
147+
mainWindow.webContents.send('history-undo');
148+
},
149+
enabled,
150+
},
151+
{
152+
label: 'Redo',
153+
click: () => {
154+
mainWindow.webContents.send('history-redo');
155+
},
156+
enabled,
157+
},
158+
{ type: 'separator' },
159+
{
160+
label: 'Cut',
161+
click: () => {
162+
mainWindow.webContents.send('cut');
163+
},
164+
enabled,
165+
},
166+
{
167+
label: 'Copy',
168+
click: () => {
169+
mainWindow.webContents.send('copy');
170+
},
171+
enabled,
172+
},
173+
{
174+
label: 'Paste',
175+
click: () => {
176+
mainWindow.webContents.send('paste');
177+
},
178+
enabled,
179+
},
180+
{ type: 'separator' },
181+
{
182+
label: 'Duplicate',
183+
accelerator: 'CmdOrCtrl+D',
184+
click: () => {
185+
mainWindow.webContents.send('duplicate');
186+
},
187+
enabled,
188+
},
189+
{
190+
label: 'Duplicate with Connections',
191+
accelerator: 'CmdOrCtrl+Shift+D',
192+
click: () => {
193+
mainWindow.webContents.send('duplicate-with-input-edges');
194+
},
195+
enabled,
196+
},
197+
],
198+
},
199+
]
200+
: [
201+
{
202+
label: 'Edit',
203+
submenu: [
204+
{
205+
label: 'Undo',
206+
accelerator: 'CmdOrCtrl+Z',
207+
registerAccelerator: false,
208+
click: () => {
209+
mainWindow.webContents.send('history-undo');
210+
},
211+
enabled,
212+
},
213+
{
214+
label: 'Redo',
215+
accelerator: 'CmdOrCtrl+Y',
216+
registerAccelerator: false,
217+
click: () => {
218+
mainWindow.webContents.send('history-redo');
219+
},
220+
enabled,
221+
},
222+
{ type: 'separator' },
223+
{
224+
label: 'Cut',
225+
accelerator: 'CmdOrCtrl+X',
226+
registerAccelerator: false,
227+
click: () => {
228+
mainWindow.webContents.send('cut');
229+
},
230+
enabled,
231+
},
232+
{
233+
label: 'Copy',
234+
accelerator: 'CmdOrCtrl+C',
235+
registerAccelerator: false,
236+
click: () => {
237+
mainWindow.webContents.send('copy');
238+
},
239+
enabled,
240+
},
241+
{
242+
label: 'Paste',
243+
accelerator: 'CmdOrCtrl+V',
244+
registerAccelerator: false,
245+
click: () => {
246+
mainWindow.webContents.send('paste');
247+
},
248+
enabled,
249+
},
250+
{ type: 'separator' },
251+
{
252+
label: 'Duplicate',
253+
accelerator: 'CmdOrCtrl+D',
254+
registerAccelerator: false,
255+
click: () => {
256+
mainWindow.webContents.send('duplicate');
257+
},
258+
enabled,
259+
},
260+
{
261+
label: 'Duplicate with Connections',
262+
accelerator: 'CmdOrCtrl+Shift+D',
263+
registerAccelerator: false,
264+
click: () => {
265+
mainWindow.webContents.send('duplicate-with-input-edges');
266+
},
267+
enabled,
268+
},
269+
],
270+
},
271+
]),
208272
{
209273
label: 'View',
210274
submenu: [

0 commit comments

Comments
 (0)