Overlay windows & pass through clicks

With a transparent window, it's possible to create an "overlay" for external application window.

Your app window can also become "invisible" to clicks meaning the clicks will pass through to the underlying content beneath.

This is useful for creating floating utility apps, extending the functionality of external applications or creating deep integrations with external applications.


How To:

In this example, we're building an overlay window that attaches to the currently focused window, and has draggable floating panels.

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FT3peoJDyRHpBMhyc2EMU%2FoverlayWindows.gif?alt=media&token=dd101d97-5666-4417-ae04-fdc2b636e385" alt=""><figcaption></figcaption></figure>

You may be confused at what you're looking at - so let's dive into what this actually is.

This is a web page with a transparent background. The web page is fitting it's size to fit that of the focused window.

Here's a look at what it looks like inside the Bubble editor.

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FuUKS5GzKy6IDkU1ve2wA%2Fimage.png?alt=media&token=6c53cd76-9771-48df-a074-bf8f31faa369" alt=""><figcaption></figcaption></figure>

To accomplish this, we need two things

1. Control over our browser window with the Windows Element
2. Information about the external applications running with the Applications Element


Step 1.

We need to create our Window with the correct settings.

- Set Titlebar Style to None
This makes our new window frameless, and removes the window controls.

- Set Transparent Background to yes
This makes our application background transparent - Note: be sure to set your page to transparent in the Bubble editor as well.

- Set Always On Top to yes
This makes our window stay above others, even when it's not focused.

- Set Has Window Shadow to no
Removes the subtle window shadow.

- Set Ignore Mouse Events to yes
Makes the application not respond to mouse clicks.

- Set Forward Mouse Events to yes
Makes clicks "pass through" the application to whatever is beneath.

- Set Is Visible On All Workspaces to yes
Only needed on macOS. This makes your application visible if the user switches workspaces (ex. If the user goes full screen)

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FA7d1bq0Sp6dXHGTL0qtw%2Fimage.png?alt=media&token=06088a5d-0d90-43b8-b148-b4db2d807073" alt=""><figcaption></figcaption></figure>

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FldiDNZu0KYSmbvK93dVb%2Fimage.png?alt=media&token=27faa90d-a6be-4996-8f42-6845f1c67ef7" alt=""><figcaption></figcaption></figure>


Step 2.

Next we need to specify which application to "track" with the Start Window Overlay action. If no application is specified, it defaults to always tracking the Active Application , meaning the overlay will follow which ever application is currently being focused.
<br>

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FXtmQd1v5OXuyCwOwaX4R%2Fimage.png?alt=media&token=822b0c87-b0f8-4ccf-8f80-5bfcf75b9cc3" alt=""><figcaption></figcaption></figure>


Step 3.

Next we'll add some simple UI to test with.

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2F3GeS70zJDqiQLywZVDID%2Fimage.png?alt=media&token=ead21ca9-370d-43b1-9a94-2e3336788926" alt=""><figcaption></figcaption></figure>

Now we should see our new UI floating over external windows.

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FduFPxYazaRJAlp0zLkF2%2FoverlayWindowsStep3.gif?alt=media&token=e0bca30f-5702-4444-9bdf-d7a260035900" alt=""><figcaption></figcaption></figure>


Step 4.

Now we'll work on making the UI clickable. Currently, our app is ignoring all clicks, and clicks will be passed to the underlying content.

You could have a hotkey to make your elements triggered using the Global Shortcuts Element, or in our case, we're going to detect when our UI is hovered.

While clicks are ignored by our application, it still responds to a couple of useful event listeners. The "mouseenter" event will fire when an element is hovered, and the "mouseleave" will fire when the element is no longer hovered.

For demonstration purposes, we'll use this free plugin to apply these event listeners to one of our elements.

Set the ID Attribute of the element, and add the hoverListener element to the page with the same element_id as the property.

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FuIqfprKmmJqUbwBApBn9%2Fimage.png?alt=media&token=58e470ce-e2c9-4ed9-9cb1-58af8d166bae" alt=""><figcaption></figcaption></figure> <figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2Fbxsuq43CMDKySOv8A33e%2Fimage.png?alt=media&token=aa087181-e936-45ad-95ae-967f9473df09" alt=""><figcaption></figcaption></figure> <br>

Then, set up the "on mouse over" and "on mouse out" events.<br>

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FIbUWQWVtSm2pSHgjh63T%2Fimage.png?alt=media&token=412aab4a-4810-49f1-b25c-82e95765c04f" alt=""><figcaption></figcaption></figure>

When the element detects a hover event, we'll make our application start responding to clicks by updating the window properties.

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2F8HKaKDvvO2nP4eolsYBv%2Fimage.png?alt=media&token=b3eb9bed-695c-4a80-9f51-5ba91b465e2b" alt=""><figcaption></figcaption></figure>

And vice versa when the element is no longer hovered.

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2FpUiwcYlTTFFI18fyp26K%2Fimage.png?alt=media&token=25c1d226-f05f-4e3e-a297-f1438d37fb2c" alt=""><figcaption></figcaption></figure>

And now the final result:

<figure><img src="https://909455594-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC8kwY8yODXmNxAtaN0Ej%2Fuploads%2F3soMWH91aHrr2ESfqrHK%2FclickDetected.gif?alt=media&token=042b7710-8c42-47fa-9c36-988b36471df6" alt=""><figcaption></figcaption></figure>


Pro Tip:

Use the Draggable Elements plugin by Bubble to make draggable groups.

Pro Tip:

macOS doesn't always accurately report the active window when the focused application has multiple windows.

Use the Refresh Application List action, and filter by windows with the same processId as the active application to find other windows to attach to.