1 Reply
      Latest reply on Oct 5, 2019 11:11 PM by digitalturbulence
      digitalturbulence Level 1 Level 1 (0 points)

        I'm currently porting my TrashMail.com Extension from Google Chrome again to Safari Extensions.

        However I would like to use native UI Cocoa components instead of "cloning" UI elements in HTML.

         

        I'm creating a extension to provide disposable email address. If someone clicks in the context menu "Paste disposable email address", then it should create a window, asking for some parameters and then paste it into the form field.

        We created this for Google Chrome, this is how it looks:

        Context menu:

         

        And then it should create a window:

        However: What is bad, the window and the content is pure HTML5 code with CSS styles, that it looks like a native operating system UI element.

         

        So instead doing this in HTML5 I would like to do it with a normal XIB file and writing Swift native code that the user have the best user experience. There should be no HTML5 code for the addon. I want that it looks and feel perfectly as the operating system macOS.

         

        Is this possible?

        When I try to start a simple NSAlert dialog, I get already the following error message:

        "no service marshals available for modal session"

         

        I created a feedback ID for this: FB7348486

        "Simple UI functionality broken or disabled in Safari Extension"

         

        I know that Firefox had in the past a similar functionality with XUL, it was very great for the user experience, it displayed the native operating system widgets. Unfortunately they removed it.

        • Re: Want to use native UI Cocoa components
          digitalturbulence Level 1 Level 1 (0 points)

          I found a workarround:

          Its exactly what some people here wrote:

          The addon must use the popover (so in the Info.plist SFSafariToolbarItem.Action must be set to "Popover"). Everything can only be launched by the SafariExtensionViewController. Starting from SafariExtensionViewController everything is then possible (even NSAlert modal popups). The only "problem" is, that popover is shown, even if not required. I guess Apple wants that Safari Extensions should use mainly the popover for most tasks. So I will redeisgn my Extension that it uses in most cases the popover. Apple should know, that in some cases the popover will be displayed with empty or "non informative" content, just because its needed. I can now create my Extension by doing it 100% in Cocoa (without HTML5 :-)).