Panel Submenus show MacOS system services



  • Some Panels show the MacOS "AutoFill" service at the bottom of the hamburger Submenu.
    Not consistently, and not everywhere.
    It seems to depend on whether an input field in the panel has focus - which makes sense...

    Not a big deal, but seldomly relevant.

    BR/ Lars Herold

    VS 1.2.030
    Mac mini M2 Pro
    Mac OS Sonoma 14.5

    0_1719054908326_Panel_Submenu_AutoFill.png


  • administrators

    @larsherold Interesting, this seems to be something added by MacOS automatically (maybe an accessibility feature).
    I will open a bug on this, to try to find out more.



  • @VectorStyler Yes, I'm not a coder, but it may be an API-feature of sorts.
    Previously only a Safari thing, but now available in most/all desktop apps in the Edit menu, active when the caret is placed in an input field.. Lets you pick and enter name, address and so on from contacts or enter passwords from the keychain.

    BR Lars Herold



  • A robot friend says this - may help, may not:

    To fix unexpected autofill or contacts in macOS context menus using C++ and Objective-C++, check these areas:

    1. Context Menu Implementation:

      • Ensure menus only show relevant items for the context.
    2. Event Handling:

      • Verify correct handling of right-click events.
    3. Input Field Attributes:

      • Disable unwanted autofill attributes (e.g., autocomplete="off").
    4. Custom Menu Items:

      • Remove unwanted system items and ensure custom items are properly defined.
    5. Debugging and Logging:

      • Add logs to trace unwanted menu additions.
      • Use Xcode Instruments for profiling.
    6. Frameworks and Libraries:

      • Check third-party libraries for side effects.
      • Update to latest versions.

    Here is an example of how to implement a context menu in C++ with Objective-C++:

    // ViewController.h
    #import <Cocoa/Cocoa.h>

    @interface ViewController : NSViewController <NSMenuDelegate>
    @end

    // ViewController.mm
    #import "ViewController.h"

    @implementation ViewController

    • (void)viewDidLoad {
      [super viewDidLoad];

      NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Context Menu"];
      [menu setDelegate:self];

      NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Custom Action"
      action:@selector(customAction)
      keyEquivalent:@""];
      [menu addItem:menuItem];

      [self.view setMenu:menu];
      }

    • (void)customAction {
      // Handle custom action
      }

    • (void)menuNeedsUpdate:(NSMenu *)menu {
      [menu removeAllItems];
      NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Dynamic Action"
      action:@selector(customAction)
      keyEquivalent:@""];
      [menu addItem:menuItem];
      }

    @end

    // main.cpp
    #include <Cocoa/Cocoa.h>

    int main(int argc, const char * argv[]) {
    return NSApplicationMain(argc, argv);
    }

    In this example, ViewController implements the NSMenuDelegate protocol to dynamically update the context menu. The menuNeedsUpdate: method ensures that the context menu only contains relevant items. This example combines C++ (in main.cpp) with Objective-C++ (in ViewController.mm), which is commonly used in macOS development.