Post

Replies

Boosts

Views

Activity

Reply to Badge label not appearing in Monterey 12.0.1
Curiously, with Monterey and subsequent macOS versions up to and including Sonoma, the Lazarus GUI program worked on some machines but not others for no reason I can determine (I have a stable of Mac minis :) Anyway, while the Lazarus GUI version has this unreliability issue from Monterey onwards, my pure Pascal program below does not. It works on all machines and all macOS versions. program badger; {$mode objfpc}{$H+} {$modeswitch objectivec1} uses CocoaAll; type { TMyDelegate } TMyDelegate = objcclass(NSObject) public procedure BadgeButtonClick(sender : id); message 'BadgeButtonClick:'; procedure UnBadgeButtonClick(sender : id); message 'UnBadgeButtonClick:'; end; var appName : NSString; window : NSWindow; myBadgeButton : NSButton; myUnBadgeButton : NSButton; myDelegate : TMyDelegate; procedure TMyDelegate.BadgeButtonClick(sender : id); begin NSApp.dockTile.setBadgeLabel(NSStr('12')); end; procedure TMyDelegate.UnBadgeButtonClick(sender : id); begin NSApp.dockTile.setBadgeLabel(Nil); end; begin // app and window creation NSApp := NSApplication.sharedApplication; NSApp.setActivationPolicy(NSApplicationActivationPolicyRegular); appName := NSStr('Badger'); window := NSWindow.alloc.initWithContentRect_styleMask_backing_defer(NSMakeRect(0, 0, 200, 200), NSTitledWindowMask or NSClosableWindowMask or NSMiniaturizableWindowMask, NSBackingStoreBuffered, False); myDelegate := TMyDelegate.alloc.init; // badge button myBadgeButton := NSButton.alloc.initWithFrame(NSMakeRect(50, 100, 100, 50)); window.contentView.addSubview(myBadgeButton); myBadgeButton.setTitle(NSSTR('Badge')); myBadgeButton.setButtonType(NSMomentaryLightButton); myBadgeButton.setBezelStyle(NSRoundedBezelStyle); // unbadge button myUnBadgeButton := NSButton.alloc.initWithFrame(NSMakeRect(50, 60, 100, 50)); window.contentView.addSubview(myUnBadgeButton); myUnBadgeButton.setTitle(NSSTR('UnBadge')); myUnBadgeButton.setButtonType(NSMomentaryLightButton); myUnBadgeButton.setBezelStyle(NSRoundedBezelStyle); // badge button event handler myBadgeButton.setTarget(myDelegate); myBadgeButton.setAction(ObjCSelector(myDelegate.BadgeButtonClick)); // unbadge button event handler myUnBadgeButton.setTarget(myDelegate); myUnBadgeButton.setAction(ObjCSelector(myDelegate.UnBadgeButtonClick)); // Window showing and app running window.center; window.setTitle(appName); window.makeKeyAndOrderFront(Nil); NSApp.activateIgnoringOtherApps(True); NSApp.run; end. As to the UNUserNotificationCenter, this is currently not available in Lazarus (due to somewhat outdated Pascalised Cocoa headers), but thanks for responding!
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’23
Reply to Badge label not appearing in Monterey 12.0.1
Curiously, with Monterey and subsequent macOS versions up to and including Sonoma, the Lazarus GUI program worked on some machines but not others for no reason I can determine (I have a stable of Mac minis :) Anyway, while the Lazarus GUI version has this unreliability issue from Monterey onwards, my pure Pascal program below does not. It works on all machines and all macOS versions. program badger; {$mode objfpc}{$H+} {$modeswitch objectivec1} uses CocoaAll; type { TMyDelegate } TMyDelegate = objcclass(NSObject) public procedure BadgeButtonClick(sender : id); message 'BadgeButtonClick:'; procedure UnBadgeButtonClick(sender : id); message 'UnBadgeButtonClick:'; end; var appName : NSString; window : NSWindow; myBadgeButton : NSButton; myUnBadgeButton : NSButton; myDelegate : TMyDelegate; procedure TMyDelegate.BadgeButtonClick(sender : id); begin NSApp.dockTile.setBadgeLabel(NSStr('12')); end; procedure TMyDelegate.UnBadgeButtonClick(sender : id); begin NSApp.dockTile.setBadgeLabel(Nil); end; begin // app and window creation NSApp := NSApplication.sharedApplication; NSApp.setActivationPolicy(NSApplicationActivationPolicyRegular); appName := NSStr('Badger'); window := NSWindow.alloc.initWithContentRect_styleMask_backing_defer(NSMakeRect(0, 0, 200, 200), NSTitledWindowMask or NSClosableWindowMask or NSMiniaturizableWindowMask, NSBackingStoreBuffered, False); myDelegate := TMyDelegate.alloc.init; // badge button myBadgeButton := NSButton.alloc.initWithFrame(NSMakeRect(50, 100, 100, 50)); window.contentView.addSubview(myBadgeButton); myBadgeButton.setTitle(NSSTR('Badge')); myBadgeButton.setButtonType(NSMomentaryLightButton); myBadgeButton.setBezelStyle(NSRoundedBezelStyle); // unbadge button myUnBadgeButton := NSButton.alloc.initWithFrame(NSMakeRect(50, 60, 100, 50)); window.contentView.addSubview(myUnBadgeButton); myUnBadgeButton.setTitle(NSSTR('UnBadge')); myUnBadgeButton.setButtonType(NSMomentaryLightButton); myUnBadgeButton.setBezelStyle(NSRoundedBezelStyle); // badge button event handler myBadgeButton.setTarget(myDelegate); myBadgeButton.setAction(ObjCSelector(myDelegate.BadgeButtonClick)); // unbadge button event handler myUnBadgeButton.setTarget(myDelegate); myUnBadgeButton.setAction(ObjCSelector(myDelegate.UnBadgeButtonClick)); // Window showing and app running window.center; window.setTitle(appName); window.makeKeyAndOrderFront(Nil); NSApp.activateIgnoringOtherApps(True); NSApp.run; end. As to the UNUserNotificationCenter, this is currently not available in Lazarus (due to somewhat outdated Pascalised Cocoa headers), but thanks for responding!
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’23
Reply to Badge label not appearing in Monterey 12.0.1
Upgrading to Monterey 12.1 made no difference. I also notice the App Store dock icon no longer shows a badge for apps to be updated, but the System Preferences dock icon does show when there's an system software update.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Where to start with a launchd daemon?
I have updated SampleD.c and attached it below. SampleD.c - https://developer.apple.com/forums/content/attachment/034c454f-ea4e-403a-890c-c4206f0ee1c5
Replies
Boosts
Views
Activity
May ’21
Reply to Where to start with a launchd daemon?
And now nearly five years later, it is still not updated, but it has been "archived" with no obvious replacement. The Apple documentation seems to be archived these days instead of being updated which is not helpful.
Replies
Boosts
Views
Activity
May ’21
Reply to Where did they move the link to "Guides and Sample Code" at developer.apple.com?
Seems the Guides and sample code have been disappeared again. The Documentation page at https://developer.apple.com/documentation/ is next to useless. The only useful information seems to be in the Archive of documentation that is no longer maintained and has no up to date version or replacement. <sigh/>
Replies
Boosts
Views
Activity
Apr ’21