Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 01-22-2021, 04:39 AM   #1
Amberience
Human being with feelings
 
Amberience's Avatar
 
Join Date: Oct 2006
Location: swing on the spiral of our divinity
Posts: 2,242
Default Is there a way to check if a docked mixer is in focus or is the current context?

Code:
function Msg(param) 
  reaper.ShowConsoleMsg(tostring(param).."\n")
end

mixer_handle, isDocked = reaper.BR_Win32_GetMixerHwnd()
focus = reaper.BR_Win32_GetFocus()


if mixer_handle == focus then
  Msg('mixer focused')
else
  Msg('mixer is not focused')
end
Got this bit of code. And it works for checking whether I am focused on the mixer when it is floating in it's own window. But it does not work when the mixer is docked.

Is there a way to return a boolean based on whether the DOCKED mixer is in focus or is the current/latest context???
Amberience is offline   Reply With Quote
Old 01-22-2021, 10:01 AM   #2
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

I'm not sure there is anything to detect that or not, but using a couple functions from the js_ReaScriptAPI extension seems to be working here on Win10,..

Code:
function Msg(param) 
  reaper.ShowConsoleMsg(tostring(param).."\n")
end

function IsMixerFocused()
  local mixer_handle, isDocked = reaper.BR_Win32_GetMixerHwnd()
  if not mixer_handle then return end
  if mixer_handle == reaper.BR_Win32_GetForegroundWindow() then
    return true -- Mixer window has focus (not docked)
  else -- check if focused window is child of Mixer
    local child_focus = reaper.BR_Win32_GetFocus() 
    local retval, list = reaper.JS_Window_ListAllChild(mixer_handle)
    for adr in list:gmatch("[^,]+") do 
      if reaper.JS_Window_HandleFromAddress(adr) == child_focus then 
        return true
      end
    end
  end
end

if IsMixerFocused() then
  Msg('mixer focused')
else
  Msg('mixer is not focused')
end

Last edited by Edgemeal; 01-22-2021 at 10:10 AM. Reason: code comments
Edgemeal is offline   Reply With Quote
Old 01-22-2021, 10:17 AM   #3
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

This seems to be working also, and only requires the SWS extension,..
Code:
function Msg(param) 
  reaper.ShowConsoleMsg(tostring(param).."\n")
end

function  IsMixerFocused()
  local mixer_handle, isDocked = reaper.BR_Win32_GetMixerHwnd() 
  if not mixer_handle then return end
  if mixer_handle == reaper.BR_Win32_GetForegroundWindow() then
    return true -- Mixer window has focus (not docked)
  elseif reaper.BR_Win32_GetParent(reaper.BR_Win32_GetFocus()) == mixer_handle then
    return true -- focused window is child of docked Mixer
  end
end

if IsMixerFocused() then
  Msg('mixer focused')
else
  Msg('mixer is not focused')
end

Last edited by Edgemeal; 01-22-2021 at 10:24 AM.
Edgemeal is offline   Reply With Quote
Old 01-22-2021, 11:20 AM   #4
Amberience
Human being with feelings
 
Amberience's Avatar
 
Join Date: Oct 2006
Location: swing on the spiral of our divinity
Posts: 2,242
Default

Oh that's awesome, I shall try that here!

Basically I want to make copy+paste scripts that are specific to certain sections of the UI. Thanks!
Amberience 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 12:31 PM.


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