Only it does not open a modal window it uses DBus notifications.
It works a bit different to Message so here is what to consider if you want to use DBMessage not Message...
- The notification is not a Modal window so it will not lock your application while open like Message will.
- If not using DBNotify.Wait then the notification will time out and disappear after a few seconds (7 seconds on my system)
DBMessage.Wait = False
This pops open the notification, if the user clicks a button then the DBMessage_Click(Value As Integer) event fires giving the button number that was pressed.
Clicking the notification window not a button will either show a value of 0 or the Default if given.
Public Sub Main()
DBMessage.Wait = False
DBMessage.AttachTo = Me ' set this to make the DBMessage_Click() event trigger in this class.
DBMessage.Question("The Title", "The Text", ["Button 1" , "Button 2"])
' code will continue to run without waiting
End
Public Sub DBMessage_Click(Value As Integer) ' triggers if the user presses a button
Print "The user clicked button " & Value
End
DBMessage.Wait = True
This pops open the notification and every 6 seconds it renews it to keep it open. It had to be done this way as there is no way to tell if a notification has timed out and gone so the best option was to keep refreshing it.
The application will now be locked in an event loop waiting for the user to press something. On selection it does not fire the Click event but a command like DBMessage.Question() will return the value.
Public Sub Main()
DBMessage.Wait = True
Dim iAnswer As Integer = DBMessage.Question("The Title", "The Text", ["Button 1" , "Button 2"])
' now the code does not continue to run until user presses the notification
Print "The user clicked button " & iAnswer
End
Commands....
- DBMessage() or DBMessage.Info() ' info icon
- DBMessage.Question() ' ? icon
- DBMessage.Warning() ' warning icon
- DBMessage.Error() ' error icon
- DBMessage.Custom() ' any stock icon
'' Use ANY stock icon image, freedesktop stock icon specifications can be found here.. https://specifications.freedesktop.org/ ... 01s04.html
Static Public Sub Custom(Title As String, Text As String, Optional Buttons As String[], {Default} As Integer = -1, StockIcon As String = "info") As Integer
- DBMessage.Wait ' turn Wait on or off
- DBMessage.Priority ' Default is 1 DBMessage.Normal , can be Low, Normal, High or Urgent , it reset to Normal after each use.
- DBMessage.LastValue ' the last value from the last use.
- DBMessage.AttachTo ' give the form you want to get the DBMessage_Click() event, default it Application.MainWindow if set or Windows[0]
The way i have implemented a "Wait" option is just a hack and works pretty much okay on my MATE desktop but is not so great on some other desktops where is does not renew quite so seamlessly. Eg, on mate the notification renewing is barely noticeable but on Gnome-Shell it closes and opens more noticeably.
But if you have a need for non vital messages/notifications with option buttons that can time out then this should be ideal.
In the project is the DBMessage.class you can easily add to your own project and a tester application for trying it out.
Note: the icon names can be somewhat hit or miss if using non standard names that might not exist in the current icon theme. see https://specifications.freedesktop.org/ ... 01s04.html for the official freedesktop naming specs.
Have fun