OS X: Menu and Beep on KeyDown lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- Key-Real · 2021-05-02 17:40 Hi, I have two Issues under Mac OS. First: If I start the app, the menu is not usable(you can not click on it). Than I change to another Window, and go back then, I can press on the menu(It works how expected). Second: If I press a Key, the system beep sounds. I trace the Keyboard in TCocoaApp.poll (not included in the test), how to not beep ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  {$mode objfpc}{$modeswitch objectivec1} uses CocoaAll, ctypes, MacOSAll; type      TCocoaApp = objcclass (NSApplication)          procedure poll; message 'poll';      end;       TCocoaAppDelegate = objcclass (NSObject, NSApplicationDelegateProtocol)      end;  procedure TCocoaApp.poll;var  event: NSEvent;  pool: NSAutoreleasePool;begin  pool := NSAutoreleasePool.alloc.init;  event := nextEventMatchingMask_untilDate_inMode_dequeue(NSAnyEventMask, {NSDate.distantPast}nil, NSDefaultRunLoopMode, true);  if event <> nil then begin      sendEvent(event);      updateWindows;  end;  pool.release;end;  procedure SetupMainMenu;   procedure AddMenu (menu: NSMenu);  var    menuItem: NSMenuItem;  begin    menuItem := NSMenuItem.alloc.initWithTitle_action_keyEquivalent(menu.title, nil, NSSTR('')).autorelease;    menuItem.setSubmenu(menu);    NSApp.mainMenu.addItem(menuItem);  end; var  mainMenu: NSMenu;  appleMenu: NSMenu;  windowMenu: NSMenu;begin  // main menu  mainMenu := NSMenu.alloc.init.autorelease;  NSApp.setMainMenu(mainMenu);  // apple menu  appleMenu := NSMenu.alloc.initWithTitle(NSSTR('')).autorelease;  appleMenu.addItemWithTitle_action_keyEquivalent(NSSTR('Quit '+NSProcessInfo.processInfo.processName.UTF8String), objcselector('terminate:'), NSSTR('q'));  AddMenu(appleMenu);  // window menu  windowMenu := NSMenu.alloc.initWithTitle(NSSTR('Window')).autorelease;  windowMenu.addItemWithTitle_action_keyEquivalent(NSSTR('Minimize'), objcselector('performMiniaturize:'), NSSTR('m'));  windowMenu.addItemWithTitle_action_keyEquivalent(NSSTR('Zoom'), objcselector('performZoom:'), NSSTR(''));  AddMenu(windowMenu);end; procedure Cocoa_Init;var  pool: NSAutoreleasePool;  app: TCocoaApp;  delegate: TCocoaAppDelegate;begin     // https://hero.handmade.network/forums/code- discussion/t/1409-main_game_loop_on_os_x   pool := NSAutoreleasePool.alloc.init;   app := TCocoaApp(TCocoaApp.sharedApplication);    delegate := TCocoaAppDelegate.alloc.init;  app.setDelegate(delegate);   NSApp.setActivationPolicy(NSApplicationActivationPolicyRegular);  NSApp.activateIgnoringOtherApps(true);   if NSApp.mainMenu = nil then SetupMainMenu;    app.finishLaunching;  pool.release;end;  procedure Cocoa_PollEvents;begin  // note: do we really need to call on main thread? isn't the first thread "main"?  TCocoaApp(TCocoaApp.sharedApplication).poll;  NSApp.performSelectorOnM ainThread_withObject_waitUntilDone(objcselector('poll'), nil, true);end;  procedure Cocoa_CreateWindow(width, height: integer; title: PChar);const  NSWindowCollectionBehaviorFullScreenPrimary = 1 shl 7 { available in 10_7 };var  window: NSWindow;  windowFlags: NSUInteger = 0;begin  windowFlags := NSTitledWindowMask + NSClosableWindowMask + NSMiniaturizableWindowMask + NSResizableWindowMask;  window := NSWindow.alloc.initWithContentRect_s tyleMask_backing_defer(NSMakeRect(123, 123, width, height ), windowFlags, NSBackingStoreBuffered, false);  window.setTitle(NSSTR(title));  window.setCollectionBehavior(NSWindowC ollectionBehaviorFullScreenPrimary);  window.setAcceptsMouseMovedEvents(true);  window.makeKeyAndOrderFront(nil);end;   begin  Cocoa_Init;  Cocoa_CreateWindow(640,480,'test');   repeat    Cocoa_PollEvents;    until false; end.    thx ---------------------------------------------------------------------- trev · 2021-05-02 23:31 1. Did you create and populate an application bundle for your executable? 2. See Prevent "not allowed" beep after keystroke.