Back to Wails

Spotlight Example

v3/examples/spotlight/README.md

2.13.02.5 KB
Original Source

Spotlight Example

This example demonstrates how to create a Spotlight-like launcher window using the CollectionBehavior option on macOS.

Features

  • Appears on all Spaces: Using MacWindowCollectionBehaviorCanJoinAllSpaces, the window is visible across all virtual desktops
  • Overlays fullscreen apps: Using MacWindowCollectionBehaviorFullScreenAuxiliary, the window can appear over fullscreen applications
  • Combined behaviors: Demonstrates combining multiple behaviors with bitwise OR
  • Floating window: MacWindowLevelFloating keeps the window above other windows
  • Accessory app: Doesn't appear in the Dock (uses ActivationPolicyAccessory)
  • Frameless design: Clean, borderless appearance with translucent backdrop

Running the example

bash
go run .

Note: This example is macOS-specific due to the use of CollectionBehavior.

Combining CollectionBehaviors

Behaviors can be combined using bitwise OR (|):

go
CollectionBehavior: application.MacWindowCollectionBehaviorCanJoinAllSpaces |
                    application.MacWindowCollectionBehaviorFullScreenAuxiliary,

CollectionBehavior Options

These are bitmask values that can be combined:

Space behavior:

OptionDescription
MacWindowCollectionBehaviorDefaultUses FullScreenPrimary (default)
MacWindowCollectionBehaviorCanJoinAllSpacesWindow appears on all Spaces
MacWindowCollectionBehaviorMoveToActiveSpaceMoves to active Space when shown
MacWindowCollectionBehaviorManagedDefault managed window behavior
MacWindowCollectionBehaviorTransientTemporary/transient window
MacWindowCollectionBehaviorStationaryStays stationary during Space switches

Fullscreen behavior:

OptionDescription
MacWindowCollectionBehaviorFullScreenPrimaryCan enter fullscreen mode
MacWindowCollectionBehaviorFullScreenAuxiliaryCan overlay fullscreen apps
MacWindowCollectionBehaviorFullScreenNoneDisables fullscreen
MacWindowCollectionBehaviorFullScreenAllowsTilingAllows side-by-side tiling

Use Cases

  • Launcher apps (like Spotlight, Alfred, Raycast)
  • Quick capture tools (notes, screenshots)
  • System utilities that need to be accessible anywhere
  • Overlay widgets that should appear over fullscreen apps

Status

PlatformStatus
MacWorking
WindowsN/A (macOS-specific feature)
LinuxN/A (macOS-specific feature)