# Floating menu focus change

**URL:** <https://community.folivora.ai/t/floating-menu-focus-change/43314>\
**Category:** Bugs or Unexpected Behavior\
**Created:** [April 19, 2025, 7:29am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314 "2025-04-19T07:29:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimaldis](https://community.folivora.ai/user_avatar/community.folivora.ai/kimaldis/32/2041_2.png) [@kimaldis](https://community.folivora.ai/u/kimaldis)\
**Post date:** [April 19, 2025, 7:29am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/1 "2025-04-19T07:29:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [April 19, 2025, 7:40am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/2 "2025-04-19T07:40:02Z")

</div>

which version of BTT are you on? (there was a recent fix related to webview focus, might be in the alphas)

---

<div class="post-metadata">

**Author:** ![kimaldis](https://community.folivora.ai/user_avatar/community.folivora.ai/kimaldis/32/2041_2.png) [@kimaldis](https://community.folivora.ai/u/kimaldis)\
**Post date:** [April 19, 2025, 8:01am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/3 "2025-04-19T08:01:57Z")

</div>

I just installed 5.3.22, still getting the same problem. I've also tried window save/restore actions.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [April 19, 2025, 8:26am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/4 "2025-04-19T08:26:12Z")

</div>

I‘ll check later today! Maybe a similar issue is still there for when using JS.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [April 19, 2025, 2:01pm UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/5 "2025-04-19T14:01:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kimaldis](https://community.folivora.ai/user_avatar/community.folivora.ai/kimaldis/32/2041_2.png) [@kimaldis](https://community.folivora.ai/u/kimaldis)\
**Post date:** [April 19, 2025, 8:54pm UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/6 "2025-04-19T20:54:21Z")

</div>

I’ll put together something more general first thing

---

<div class="post-metadata">

**Author:** ![kimaldis](https://community.folivora.ai/user_avatar/community.folivora.ai/kimaldis/32/2041_2.png) [@kimaldis](https://community.folivora.ai/u/kimaldis)\
**Post date:** [April 19, 2025, 8:57pm UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/7 "2025-04-19T20:57:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [April 20, 2025, 6:36am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/8 "2025-04-20T06:36:16Z")

</div>

I think telling alone should not cause it to focus. Which apple script functions are you calling on BTT to refresh?

---

<div class="post-metadata">

**Author:** ![kimaldis](https://community.folivora.ai/user_avatar/community.folivora.ai/kimaldis/32/2041_2.png) [@kimaldis](https://community.folivora.ai/u/kimaldis)\
**Post date:** [April 20, 2025, 9:20am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/9 "2025-04-20T09:20:21Z")

</div>

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:

```auto
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:

```javascript
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.

---

<div class="post-metadata">

**Author:** ![kimaldis](https://community.folivora.ai/user_avatar/community.folivora.ai/kimaldis/32/2041_2.png) [@kimaldis](https://community.folivora.ai/u/kimaldis)\
**Post date:** [April 21, 2025, 7:52am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/10 "2025-04-21T07:52:15Z")

</div>

Kicking myself: 'Do not autofocus webview' was off. All good now.

Thanks for your time, Andreas and sorry for the noise.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [April 21, 2025, 7:58am UTC](https://community.folivora.ai/t/floating-menu-focus-change/43314/11 "2025-04-21T07:58:50Z")

</div>

ah great, probably there should be a checkbox on the js action itself. Need to align the various focus options
