View Issue Details

IDProjectCategoryView StatusLast Update
0035688LazarusLCLpublic2019-06-12 21:52
ReporterChris RordenAssigned ToDmitry Boyarintsev 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformMacBook 2012 Retina 13"OSDarwinOS Version10.11.6
Product Version2.1 (SVN)Product Build61326 
Target VersionFixed in Version 
Summary0035688: Cocoa: popNotifier.ShowAtPos does not show notification
DescriptionThe TPopupNotifier does not appear to work for Cocoa.
Steps To Reproduceprocedure TForm1.PopUpMsg();
var
popNOtifier: TPopupNotifier;
begin
popNotifier:=TPopupNotifier.Create(Self);
popNotifier.Title:='User notification';
popNotifier.Text:='a message';
popNotifier.ShowAtPos(20, 20);
Sleep(5000);
popNOtifier.hide; // this has no effect in Ubuntu
end;
Additional InformationOne option might be to use the NSUserNotification, alternatively, NSUserNotification could be added to macosext to provide a convenient but MacOS specific way to briefly show messages that automatically close.

- (IBAction)notifyNotAllVolumesLoaded: (int) loadedVols RawVols: (int) rawVols;
{
    NSUserNotification *notification = [[NSUserNotification alloc] init];
    notification.title = [NSString stringWithFormat:@"Loaded %d of %d volumes", loadedVols, rawVols];
    notification.informativeText = @"Reason: The preference 'Only initial volumes' is selected";
    notification.soundName = NULL;
    [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
    [NSTimer scheduledTimerWithTimeInterval: 4.5 target:self selector: @selector(closePopup) userInfo:self repeats:NO];
}
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetCocoa
Attached Files

Activities

Chris Rorden

2019-06-08 01:52

reporter  

popup.zip (132,702 bytes)

Dmitry Boyarintsev

2019-06-12 16:57

developer   ~0116695

1. the way it's written in the sample it shouldn't work in any system.
Sleep(5000) stops processing the event loop for 5 seconds, thus preventing elements from drawing.
Also sleep is immediately followed by .hide.
Since macOS optimizes drawing - two commands "show" and then "hide" tells macOS not to do draw anything at all.

2. in order to make the sample work on macOS (i presume the same fix would apply to Ubuntu), you need to process events.
procedure TForm1.PopUpMsg();
var
popNOtifier: TPopupNotifier;
t: qword;
begin
popNotifier:=TPopupNotifier.Create(Self);
popNotifier.Title:='User notification';
popNotifier.Text:='a message';
popNotifier.ShowAtPos(20, 20);
t:=GetTickCount64;
while GetTickCount64-t < 5000 do
  Application.ProcessMessages;
popNOtifier.hide; // this has no effect in Ubuntu
end;

3. Current implementation of TPopupNotifier doesn't imply any widgetset specific implementation.
Thus use of AppKit APIs is not really possible in the current implementation.

Chris Rorden

2019-06-12 21:52

reporter   ~0116702

Sorry, should have checked with other widget sets. Your code fixes this

Issue History

Date Modified Username Field Change
2019-06-08 01:52 Chris Rorden New Issue
2019-06-08 01:52 Chris Rorden File Added: popup.zip
2019-06-12 16:57 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-06-12 16:57 Dmitry Boyarintsev Status new => resolved
2019-06-12 16:57 Dmitry Boyarintsev Resolution open => no change required
2019-06-12 16:57 Dmitry Boyarintsev LazTarget => -
2019-06-12 16:57 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-06-12 16:57 Dmitry Boyarintsev Note Added: 0116695
2019-06-12 21:52 Chris Rorden Status resolved => closed
2019-06-12 21:52 Chris Rorden Note Added: 0116702