Skip to content

rumps.Window and rumps.alert always appear behind current window. rumps.Window not accept keyboard input. #225

Description

@PoeticPete

Dusting off a rumps project from a few years ago. I'm now on rumps==0.4.0, pyobjc==12.0, and MacOS 15.7.1 (24G231).

With the upgrades, presenting a Window or alert always results in the window being presented behind my active window. I see the same issue mentioned in #221.

I think the Windowand alert should be presented on top of everything by default. This is my workaround for now:

import rumps
from AppKit import (
    NSApplication,
    NSApplicationActivationPolicyAccessory,
    NSApplicationActivationPolicyRegular,
    NSFloatingWindowLevel,
)


class AwesomeStatusBarApp(rumps.App):
    @rumps.clicked("Preferences")
    def prefs(self, _):
        app = NSApplication.sharedApplication()

        # Temporarily change to regular app to accept keyboard input
        app.setActivationPolicy_(NSApplicationActivationPolicyRegular)
        app.activateIgnoringOtherApps_(True)

        w = rumps.Window(
            title="blah blah blah",
            message="typing in here works now",
            default_text="",
        )

        alert_window = w._alert.window()
        alert_window.setLevel_(NSFloatingWindowLevel)
        alert_window.makeKeyAndOrderFront_(None)

        response = w.run()

        print(response)

        # Change back to accessory app (menu bar only)
        app.setActivationPolicy_(NSApplicationActivationPolicyAccessory)


if __name__ == "__main__":
    AwesomeStatusBarApp("Awesome App").run()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions