Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS DataTypes Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DataTypes/Notification
This example is the version from Sun, 17th Mar 2012.
Project "Notification.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
window1.show
window2.Left = window1.Left+Window1.Width + 20
window2.show
window3.top = window1.top + window1.Height + 30
window3.show
window4.Left = window1.Left
window4.top = window3.top
window4.show
End EventHandler
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Close()
NotificationMBS.UnregisterReceiver(self)
End EventHandler
EventHandler Sub Open()
NotificationMBS.RegisterReceiver(self, "MyNotification", nil)
End EventHandler
Sub ReceivedNotification(name as string, ref as variant, tag as variant, notification as NotificationMBS)
// Part of the NotificationReceiverMBS interface
List.AddRow "Notification received."
List.AddRow " Name: "+name
List.AddRow " tag: "+tag.StringValue
Exception i as IllegalCastException
// ignore if stringvalue method fails
End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class Window2 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Close()
NotificationMBS.UnregisterReceiver(self)
End EventHandler
EventHandler Sub Open()
NotificationMBS.RegisterReceiver(self, "", window1)
NotificationMBS.RegisterReceiver(self, "", window2)
End EventHandler
Sub ReceivedNotification(name as string, ref as variant, tag as variant, notification as NotificationMBS)
// Part of the NotificationReceiverMBS interface
List.AddRow "Notification received."
List.AddRow " Name: "+name
List.AddRow " tag: "+tag.StringValue
Exception i as IllegalCastException
// ignore if stringvalue method fails
End Sub
End Class
Class Window3 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open()
o = new MyNotificationObserverMBS
End EventHandler
Property o As MyNotificationObserverMBS
End Class
Class MyNotificationObserverMBS Inherits NotificationObserverMBS
EventHandler Sub ReceivedNotification(name as string, ref as variant, tag as variant, notification as NotificationMBS)
dim list as Listbox = window3.List
List.AddRow "Notification received."
List.AddRow " Name: "+name
List.AddRow " tag: "+tag.StringValue
Exception i as IllegalCastException
// ignore if stringvalue method fails
End EventHandler
End Class
Class Window4 Inherits Window
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control EditField3 Inherits TextField
ControlInstance EditField3 Inherits TextField
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control PopupMenu1 Inherits PopupMenu
ControlInstance PopupMenu1 Inherits PopupMenu
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
dim n as new NotificationMBS
Select case PopupMenu1.ListIndex
case 0
// nothing
case 1
n.Ref = window1
case 2
n.Ref = window2
case 3
n.Ref = window3
case 4
n.Ref = window4
case 5
n.Ref = app
end Select
n.Name = EditField1.text
n.Tag = EditField3.text
n.send(n)
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
dim n as new NotificationMBS("MyNotification")
n.Tag = "Sending with MyNotification button."
NotificationMBS.Send(n)
End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
dim n as new NotificationMBS("MyNotification")
n.ref = window1
n.Tag = "Sending with MyNotification button."
NotificationMBS.Send(n)
End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action()
dim n as new NotificationMBS
Select case PopupMenu1.ListIndex
case 0
// nothing
case 1
n.Ref = window1
case 2
n.Ref = window2
case 3
n.Ref = window3
case 4
n.Ref = window4
case 5
n.Ref = app
end Select
n.Name = EditField1.text
n.Tag = EditField3.text
n.send(n)
End EventHandler
End Control
Control PushButton5 Inherits PushButton
ControlInstance PushButton5 Inherits PushButton
EventHandler Sub Action()
dim n as new NotificationMBS("MyNotification")
n.ref = window1
n.Tag = "First notification (Delayed)"
NotificationMBS.SendDelayed(n)
dim n2 as new NotificationMBS("MyNotification")
n2.ref = window1
n2.Tag = "Second notification."
NotificationMBS.Send(n2)
End EventHandler
End Control
End Class
End Project
The items on this page are in the following plugins: MBS DataTypes Plugin.