Old 07-18-2015, 10:51 AM   #1
syntetic
Human being with feelings
 
syntetic's Avatar
 
Join Date: May 2014
Posts: 160
Default Set focus to midi editor

Is it possible? please say to me
syntetic is offline   Reply With Quote
Old 07-19-2015, 12:59 AM   #2
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,541
Default

I'm not sure, but I think it's not possible.


Here's a function to set focus to different elements (no MIDI editor there)

Code:
C: void SetCursorContext(int mode, TrackEnvelope* env)

EEL: SetCursorContext(int mode, TrackEnvelope env)

Lua: reaper.SetCursorContext(integer mode, TrackEnvelope env)

Python: RPR_SetCursorContext(Int mode, TrackEnvelope env)

You must use this to change the focus programmatically. mode=0 to focus track panels, 1 to focus the arrange window, 2 to focus the arrange window and select env (or env==NULL to clear the current track/take envelope selection)
spk77 is offline   Reply With Quote
Old 07-19-2015, 05:23 AM   #3
Ozymandias
Human being with feelings
 
Join Date: Apr 2011
Posts: 144
Default

Are you running Windows? If you can't get this to work in Reaper alone, you could probably use PyWin32 or AutoHotKey to find the MIDI Editor window and make it active.
Ozymandias is offline   Reply With Quote
Old 07-19-2015, 05:30 AM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,541
Default

@syntetic
What are you trying to do exactly ?
spk77 is offline   Reply With Quote
Old 07-19-2015, 05:33 AM   #5
studio1602
Human being with feelings
 
Join Date: Jul 2014
Posts: 49
Default

It is possible, I have a shortcut set up to switch focus to the MIDI editor. But...

I set this up a long time ago, and couldn't remember the action, so I opened the action list, entered my shortcut into "Find shortcut", and, instead of the action being returned, got the message "Shortcut defined, but command not found". What?

My assumption is that there was once an action for this, but at some point, for some reason, it has been removed. I opened up reaper-kb.ini, and found my shortcut there; the command ID is 40194. If you're comfortable editing .ini files, you could add the action that way.

Anyone know why this was removed? Should it be considered deprecated?
studio1602 is offline   Reply With Quote
Old 07-19-2015, 07:04 AM   #6
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,172
Default

Quote:
Originally Posted by studio1602 View Post
It is possible, I have a shortcut set up to switch focus to the MIDI editor. But...

I set this up a long time ago, and couldn't remember the action, so I opened the action list, entered my shortcut into "Find shortcut", and, instead of the action being returned, got the message "Shortcut defined, but command not found". What?

My assumption is that there was once an action for this, but at some point, for some reason, it has been removed. I opened up reaper-kb.ini, and found my shortcut there; the command ID is 40194. If you're comfortable editing .ini files, you could add the action that way.

Anyone know why this was removed? Should it be considered deprecated?
And it still works, even if it's not listed in the action list? I wonder what happens when multiple MIDI editors are open, which does it choose?
gofer is offline   Reply With Quote
Old 07-19-2015, 07:43 AM   #7
studio1602
Human being with feelings
 
Join Date: Jul 2014
Posts: 49
Default

Quote:
Originally Posted by gofer View Post
And it still works, even if it's not listed in the action list?
Yeah, this puzzled me, too. I would never have known the command was missing if I hadn't gone looking. My guess is that even though the action has been removed from the list, the command still exists in the code.

Quote:
Originally Posted by gofer View Post
I wonder what happens when multiple MIDI editors are open, which does it choose?
Good question. I use one MIDI editor per project, so can't say.
studio1602 is offline   Reply With Quote
Old 07-19-2015, 11:20 AM   #8
syntetic
Human being with feelings
 
syntetic's Avatar
 
Join Date: May 2014
Posts: 160
Default

spk77
I want to return focus to midi editor in script, after showing/closing virtual midi keyboard, because shortcuts dont work when vkb is opened with used command send all input to vkb, there is no action for return all input to reaper except to close keyboard,
I had to use twice action close/open midi editor for return focus,
it works but with small delay & flashing windows)
syntetic is offline   Reply With Quote
Old 07-19-2015, 12:12 PM   #9
xpander
Human being with feelings
 
xpander's Avatar
 
Join Date: Jun 2007
Location: Terra incognita
Posts: 4,909
Default

Going back I found that Reaper v4.581 is the last one where the following actions were in the Actions list (so they disappeared with v4.59):

Quote:
Item: Open in last focused MIDI editor (preserve existing editor contents) 40128
Item: Open in last focused MIDI editor (clear editor first) 40193

Item: Open all track MIDI in last focused MIDI editor (clear editor first) 40134
Item: Open all track MIDI in last focused MIDI editor (preserve existing editor contents) 40194

Item: Open all project MIDI in last focused MIDI editor 41841
Maybe worth noticing is that with v4.59 the MIDI editor settings changed also in preferences, amongst them the editor focusing.

xpander is offline   Reply With Quote
Old 07-20-2015, 02:20 PM   #10
syntetic
Human being with feelings
 
syntetic's Avatar
 
Join Date: May 2014
Posts: 160
Default

actions works, but also they change horizontal scroll & zoom in midi editor
syntetic is offline   Reply With Quote
Old 01-09-2017, 01:13 AM   #11
aspiringSynthesisingAlch
Human being with feelings
 
Join Date: Feb 2014
Posts: 277
Default set focus to midi editor (as old, via shortcut, retaining view/zoom etc) SOLVED?

as title suggests, did ya fix this (if so, how - feel free to embed
Code:
reaper-kb contents 
OR
attachments
If not please say so - I think anything is possible (within reason), just a little effort required - this is within reason.

thanks!
aspiringSynthesisingAlch is offline   Reply With Quote
Old 04-19-2017, 12:57 PM   #12
lunker
Human being with feelings
 
lunker's Avatar
 
Join Date: Nov 2007
Location: Lucas, TX, USA (via Luleå, Sweden)
Posts: 987
Default

I'm not sure if this is the same question the OP asked:

I have a floating toolbar with buttons to run ReaScript programs that act on the active MIDI editor. After the programs complete, the focus is on the toolbar, instead of on the MIDI editor (which was the focused window right before I clicked the toolbar button).

Is there an API command I can put at the end of the ReaScript program to return focus to the MIDI editor? I'm getting tired of having to remember to reactivate focus on the MIDI editor after I click one of the toolbar buttons.


EDIT:
Damn -- I always seem to be able to answer my own question *after* I show my ignorance by posting it!

Before I posted, I saw the action "SWS/S&M: Cycle focused window", but didn't think it would do what I wanted. (I thought it would cycle the focus through all open windows, without me being able to know the order or which one would be the MIDI editor). I just tried it, and it does exactly what I want -- cycle the focus back and forth between the last two windows (in this case, the toolbar and the MIDI editor).

One question though: the documentation doesn't explain what the "flag" parameter does:

Code:
Main_OnCommand(int command, int flag)
It seems to work when I pass in 0 or 1 (haven't tried any other values). What is "flag" used for?
__________________
Best Regards, Ernie "lunker" Lundqvist
BDSM (Bad Dog Studio Musicians)
Windows 10 running on Z390 + i7-8700

Last edited by lunker; 04-19-2017 at 02:28 PM.
lunker is offline   Reply With Quote
Old 01-01-2018, 12:42 PM   #13
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,801
Default

DONE! in the newer versions of SWS, thanks to tack an snooks:

SN_FocusMIDIEditor()
juliansader is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.