I have a custom menu visible only in Lightroom. When the menu opens it asks Lightroom for information about the selected photo - tags, what collections contain it, resolution, etc, which it displays.
When a selection changes in Lightroom, Lightroom uses AppleScript to tell BetterTouchTool to run a Javascript function which refreshes the menu with the new selected photo information. My problem is that this process has the menu steal focus from the Lightroom main window; my shortcuts go to the menu, not lightroom . I can work round this by clicking somewhere in the Lightroom main window but it's a bit annoying. I wondered if there's a workaround?
which version of BTT are you on? (there was a recent fix related to webview focus, might be in the alphas)
I just installed 5.3.22, still getting the same problem. I've also tried window save/restore actions.
I‘ll check later today! Maybe a similar issue is still there for when using JS.
1 Like
Could you maybe share the update JS you are calling and how you are calling it via Apple Script? I wasn't able to reproduce the issue yet, but I currently don't have lightroom installed to test.
Is maybe the Apple Script you are using setting BTT as front process?
I’ll put together something more general first thing
Actually, thinking about it you’re probably right. Telling better touch tool to refresh is probably bringing it to the foreground the answer will probably be to activate Lightroom in the refresh script. I’ll check it out in the morning.
I think telling alone should not cause it to focus. Which apple script functions are you calling on BTT to refresh?
I was hoping I could replicate it in something more simple but I'm struggling a bit to figure that one out. I'm triggering the menu display. itself using an ordinary BTT keyboard shortcut and just leaving it running. Then, when my Lightroom plugin receives a selection change event it runs the following AppleScript:
tell application "BetterTouchTool" to webview_menu_item_load_html_url_js "51593D02-81AF-4891-A8E3-210AB1CB95D1" javascript_to_execute "Refresh()"
where Refresh()
is a function in the menu html:
function Refresh() {
console.log( "Refresh" )
location.reload()
}
The reload forces the menu to fetch fresh data from Lightroom. Interestingly, Lightroom is still showing as active with its menus in the menubar but it's not accepting keypresses, I just get a beep. The menu window is showing its traffic light buttons top left as active, as is the main Lightroom window. So you're right, activating Lightroom from AppleScript probably won't work, it's already active.
If I remove the location.reload() line from the javascript everything behaves.
It may be that I have to approach this differently. That's not a problem for me.
Kicking myself: 'Do not autofocus webview' was off. All good now.
Thanks for your time, Andreas and sorry for the noise.
ah great, probably there should be a checkbox on the js action itself. Need to align the various focus options