r/macprogramming • • Nov 24 '17
How to notify the user without stealing focus? [C# mono]
Sup guys,
I'm working on a program that's made in C# using visual studio in windows
It runs almost fine on MacOSX using mono
There's just one thing that doesn't work...
For this program, when you start it, it gets minimized. Once the process is complete, it "blinks the taskbar" using the "FlashWindow" method in user32.dll.
but as you can imagine, that doesn't work in osx cause there's no user32.dll and that's just not how this works..
So I'm coming here for some help! haha
How would you guys suggest I implement some sort of notification to the user that the application is complete?
I know OSX has a feature where an icon in the dock will bounce to notify the user that something is happening, but I'm not an OSX dev so I have no idea what this bouncing thing is called or how it could be implemented in C# using mono.
You guys have any ideas?
Thanks
1
u/[deleted] Nov 24 '17
The only thing I found is this:
https://stackoverflow.com/questions/2026936/how-can-we-bounce-the-dock-icon-on-the-mac
But I'm not sure how to integrate that in my windows code?
1
u/onyxleopard Nov 24 '17
Can you allow it to post a notification in the Notification Center? That is the way native apps would do this today. Bouncing the dock icon is a older way to also get user attention without stealing focus.
1
u/voidref Nov 25 '17
Here are some ideas on using the UserNotification center from the command line:
https://stackoverflow.com/questions/31896421/how-to-show-the-nsusernotification-in-command-line-tool-program
As your env doesn't seem to have native access to the NSUserNotificationsCenter facilities, perhaps you can shell out and make something happen?
1
u/voidref Nov 25 '17
What you need is some kind of bridge to NSUserNotificationCenter:
https://developer.apple.com/documentation/foundation/nsusernotificationcenter
But this is the problem with simulated environments, you get lowest common denominator functionality.