[Help] Focus the Renoise window from the tool window.

I have a tool with a window. I have been looking at this documentation. Is there any way to focus the Renoise window from the tool window?

Doc info:

-------- Functions

-- Expand the window over the entire screen, without hiding menu bars, 
-- docks and so on.
renoise.app().window:maximize()

-- Minimize the window to the dock or taskbar, depending on the OS.
renoise.app().window:minimize()

-- "un-maximize" or "un-minimize" the window, or just bring it to front.
renoise.app().window:restore()

-- Select/enable one of the global view presets, to memorize/restore
-- the user interface 'layout'.
renoise.app().window:select_preset(preset_index) 

.....etc

Something like thatrenoise.app().window:focus()??? (focus the window of renoise)

What I intend to build is the idea and turn between the window of renoise and the window of the tool, without having to close the tool, through keyboard commands.

The round-and-turn between windows using keyboard commands makes it easier to use a tool.The goal is to not have to close the tool to return to the Renoise window and that the tool window remains in the foreground.

Is there any way?

Thanks!

The round-and-turn between windows using keyboard commands makes it easier to use a tool.The goal is to not have to close the tool to return to the Renoise window and that the tool window remains in the foreground.

What does

renoise.app().window.lock_keyboard_focus

do? I’m not very well versed with LUA GUI Windows.

Anyway, forget lock_keyboard_focus, and check this out:

Ok, I opened NoodleTrap. I pressed F2 (which for me is “go to Pattern Editor”) The focus is now on Pattern Editor. Now I press another key to open up NoodleTrap - but because it is open, now the focus is on the GUI window.

Is this what you’re looking for?

Not sure if this helps but it is from my default tool setup. It means that when the tool gui is open, all the keys get passed back to renoise via the keyhandler function. i.e. return key on line 8.

The renoise.app().window.lock_keyboard_focus is toggled twice so that the users lock focus preference is not overridden, but you still get the side effect of the pattern editor being focused with each key press (each time the function runs).

This setup passes all keystrokes to renoise all the time, but you could limit it using some sort of global flag and checkbox notifier (a kind of edit mode). Or some key combination to set that global flag.

--------------
      --key Handler
      --------------
      local function my_keyhandler_func(dialog,key)
         --toggle lock focus hack, allows pattern ed to get key input
         renoise.app().window.lock_keyboard_focus = not renoise.app().window.lock_keyboard_focus
         renoise.app().window.lock_keyboard_focus = not renoise.app().window.lock_keyboard_focus
         return key
      end
     
     
      ------------------------------------------------------------------------------------------
      --Script dialog
      ------------------------------------------------------------------------------------------
      my_dialog = renoise.app():show_custom_dialog(
          TOOL_NAME, dialog_content,my_keyhandler_func)

Also key is a table with the 5 entries:

key.character
key.modifiers
key.name
key.note
key.repeated

Here is a printout in the terminal: rprint(key) --after the r key has been pressed by user on the qwerty keyboard:

--rprint() recursively prints the table: key 
rprint(key)
[character] => r
[modifiers] =>
[name] => r
[note] => 17
[repeated] => false

so if you wanted to do something with a specific key the user presses, you can do something like this:

If key.character == "r" then
  -- do something here
end

if using a flag then it would be something like this:

If (key.character == "r") and (my_global_flag == true) then  
  -- do something here
end

Ledger, could this be used to make it so that “Esc” would escape into pattern editor (edit mode on/off) and not ever close the sample recorder dialog? Cos I’m finding it damn difficult to track with edit mode on/off while sampling, without losing the sample.

renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_MIXER
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PHRASE_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_KEYZONES
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_MODULATION
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EFFECTS
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PLUGIN_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_MIDI_EDITOR

-- When true, the middle frame views (like the pattern editor) will stay focused unless alt or middle mouse is clicked. renoise.app().window.lock_keyboard_focus -> [boolean]

I do not know how this works. I’ll have to try it.

Ledger, could this be used to make it so that “Esc” would escape into pattern editor (edit mode on/off) and not ever close the sample recorder dialog? Cos I’m finding it damn difficult to track with edit mode on/off while sampling, without losing the sample.

If you want to stop keys getting back to renoise, you would have to have a dialog open all the time and it would need to be focused, so I don`t think there would be a practical solution there…

renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_MIXER
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PHRASE_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_KEYZONES
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_MODULATION
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EFFECTS
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PLUGIN_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_MIDI_EDITOR

-- When true, the middle frame views (like the pattern editor) will stay focused unless alt or middle mouse is clicked. renoise.app().window.lock_keyboard_focus -> [boolean]

I do not know how this works. I’ll have to try it.

clue: :slight_smile:

renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_MODULATION

Also the lock keyboard focus is the same as the user preference in renoise under the View menu (second entry down)

Also the lock keyboard focus is the same as the user preference in renoise under the View menu (second entry down)

Please tell me more about this - i just disabled View->Lock Keyboard Focus, and now each click to Instrument Box or Disk Browser or Pattern Editor automatically takes the keyboard focus. could I do a script that switches between where the keyboard focus is in? Like, could I toggle “keyboard focus in instrument box” or “in pattern editor” or… “in disk browser”? would be wonderful!

Please tell me more about this - i just disabled View->Lock Keyboard Focus, and now each click to Instrument Box or Disk Browser or Pattern Editor automatically takes the keyboard focus. could I do a script that switches between where the keyboard focus is in? Like, could I toggle “keyboard focus in instrument box” or “in pattern editor” or… “in disk browser”? would be wonderful!

--show automation editor
function vpd_aut_show_ae()
  --[[
  if renoise.app().window.active_lower_frame ~= renoise.ApplicationWindow.LOWER_FRAME_TRACK_AUTOMATION then
    renoise.app().window.active_lower_frame = renoise.ApplicationWindow.LOWER_FRAME_TRACK_AUTOMATION
  end
  ]]
  
  if ( renoise.app().window.lower_frame_is_visible == false ) then
    renoise.app().window.lower_frame_is_visible = true
  end
  renoise.app().window.active_lower_frame = renoise.ApplicationWindow.LOWER_FRAME_TRACK_AUTOMATION
end

This is to focus the automation editor. You can take it as an example for other areas.First you check if the area is visible or not. Then direct it there.

EDIT:Sorry, I think that is not enough. This only shows the window, but it does not focus. I have the same problem related to the approach.That from the tool, when executing a function with a button, it shows the desired area, and also the focus.It is one thing to show the area, and another thing is to mark the focus.

EDIT2:The case is: how to mark the focus?There should be some form, adding it at the end of the function, for the focus.

Yes I think Raul`s right , there is no current way to set the focus, just the ability to set the user lock mode.

EDIT2:The case is: how to mark the focus?There should be some form, adding it at the end of the function, for the focus.

Thu Jan 11 23:08:25 ~ >> sol focus
-- stay focused unless alt or middle mouse is clicked.
renoise.app().window.lock_keyboard_focus
-- Invoked as soon as the application looses focus and another app
-- because your dialog will steal the focus from all other Renoise views such as
-- rather only after editing is complete (return is pressed, or focus is lost).
-- True when the text field is focused. setting the edit_mode programatically
-- will focus the text field or remove the focus (focus the dialog) accordingly.
-- True when the text field is focused. setting the edit_mode programatically
-- will focus the text field or remove the focus (focus the dialog) accordingly.

unfortunately the renoise api only allows for lock_keyboard_focus which does not seem to have anything interesting to do with the features we want :o

same with

Thu Jan 11 23:08:28 ~ >> sol browser
-- Opens the default internet browser with the given URL. The URL can also be
-- a file that browsers can open (like xml, html files...).
-- Opens the default file browser (explorer, finder...) with the given path.
-- Diskbrowser Panel.
renoise.app().window.disk_browser_is_visible, _observable
+ "Disk Browser Directories"
+ "Disk Browser Files"
> "Global", "Automation", "Disk Browser", "Instrument Box", "Mixer",
types will show up in Renoise's disk browser and can also be loaded by drag and 
  + ["category"] = in which disk browser category the file type shows up.

there simply isn’t something to bring focus to disk browser, or to make it selected. ohwell.