diff --git a/pd/nw/index.js b/pd/nw/index.js index 7643a18b27cd91743a3bcf1acebc8246fbf67b8a..95195b20cb19ef48ee19bf10c9593a6437033bec 100644 --- a/pd/nw/index.js +++ b/pd/nw/index.js @@ -231,18 +231,6 @@ function console_find_keydown(elem, evt) { } } -function pdmenu_copy () { - alert("Please implement pdmenu_copy"); -} - -function pdmenu_selectall () { - alert("Please implement pdmenu_selectall"); -} - -function pdmenu_preferences () { - alert("Please implement pdmenu_preferences"); -} - function pdmenu_next_win () { alert("Please implement pdmenu_preferences"); } @@ -251,38 +239,6 @@ function pdmenu_previous_win () { alert("Please implement pdmenu_preferences"); } -function pdmenu_parent_win () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_console_win () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_audio_on () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_audio_off () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_test_audio () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_load_meter () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_about_pd () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_manual () { - alert("Please implement pdmenu_preferences"); -} - function pdmenu_help_browser () { alert("Please implement pdmenu_preferences"); } @@ -568,26 +524,6 @@ function nw_create_pd_window_menus () { tooltip: l("menu.prevwin_tt") })); - winmanMenu.append(new gui.MenuItem({ - type: "separator" - })); - - winmanMenu.append(new gui.MenuItem({ - label: l("menu.parentwin"), - click: pdmenu_parent_win, - //key: "a", - //modifiers: "ctrl", - tooltip: l("menu.parentwin_tt") - })); - - winmanMenu.append(new gui.MenuItem({ - label: l("menu.pdwin"), - click: pdmenu_console_win, - //key: "a", - //modifiers: "ctrl", - tooltip: l("menu.pdwin_tt") - })); - // Media menu var mediaMenu = new gui.Menu(); diff --git a/pd/nw/locales/en/translation.json b/pd/nw/locales/en/translation.json index 1f083886a61404ef7eb051a7dd9c3628e87b415e..747380ff906341cb3a256cb83af5de9314be321c 100644 --- a/pd/nw/locales/en/translation.json +++ b/pd/nw/locales/en/translation.json @@ -200,6 +200,8 @@ "prevwin_tt": "Give focus to the previous window in the stacking order", "parentwin": "Parent Window", "parentwin_tt": "give focus to the parent window of the current window", + "visible_parentwin": "Visible Parent Window", + "visible_parentwin_tt": "give focus to the closest ancestor of this window that is visible", "pdwin": "Pd Window", "pdwin_tt": "Give focus to the main Pd window", diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index d5a4f9826dda1b0aa50039ac00370a956f75813a..396484d6fce8d5003dbe4b1f0d3fecb3da1d85aa 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -1238,10 +1238,20 @@ function nw_create_patch_window_menus(name) { winmanMenu.append(new gui.MenuItem({ label: l("menu.parentwin"), - click: menu_generic, + click: function() { + pdgui.pdsend(name, "findparent", 0); + }, tooltip: l("menu.parentwin_tt"), })); + winmanMenu.append(new gui.MenuItem({ + label: l("menu.visible_parentwin"), + click: function() { + pdgui.pdsend(name, "findparent", 1); + }, + tooltip: l("menu.visible_parentwin_tt"), + })); + winmanMenu.append(new gui.MenuItem({ label: l("menu.pdwin"), click: function() { diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 9a08d364cf8262d2308e294e23996ceefb3c7bad..e4dce60f6742eb769e9c72ec71f84545c8f2fa33 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5744,19 +5744,28 @@ static void canvas_find_again(t_canvas *x) } /* following function serves mainly as a helper function for tcl/tk - and focuses first visible parent (not the immediate parent) */ -static void canvas_find_parent(t_canvas *x) + f = 0: show immediate parent + f = 1: show visible parent */ +static void canvas_find_parent(t_canvas *x, t_floatarg f) { if (x->gl_owner) { - t_glist *owner = x->gl_owner; - while (!glist_isvisible(owner) && - !owner->gl_havewindow && owner->gl_owner) - owner = owner->gl_owner; - if (glist_isvisible(owner) && owner->gl_havewindow) - canvas_vis(owner, 1); + if (f != 0) /* find visible parent */ + { + t_glist *owner = x->gl_owner; + while (!glist_isvisible(owner) && + !owner->gl_havewindow && owner->gl_owner) + owner = owner->gl_owner; + if (glist_isvisible(owner) && owner->gl_havewindow) + canvas_vis(owner, 1); + } + else /* find immediate parent */ + { + canvas_vis(glist_getcanvas(x->gl_owner), 1); + } } - else { + else + { sys_gui("menu_raise_console\n"); } } @@ -7783,7 +7792,7 @@ void g_editor_setup(void) class_addmethod(canvas_class, (t_method)canvas_find_again, gensym("findagain"), A_NULL); class_addmethod(canvas_class, (t_method)canvas_find_parent, - gensym("findparent"), A_NULL); + gensym("findparent"), A_DEFFLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_done_popup, gensym("done-popup"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_donecanvasdialog,