Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSStatusItem/Display current IP
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSStatusItem/Display current IP
This example is the version from Sun, 17th Mar 2012.
Project "Display current IP.rbp"
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() dim f as FolderItem if TargetMachO=false then MsgBox "This example needs a MachO target running on Mac OS X." quit end if s=new NSStatusItemMBS if not s.Available then MsgBox "NSStatusItem not available." quit end if call s.CreateMenu s.HighlightMode=false s.Title="IP" c=new clock c.Period=2000 c.mode=2 End EventHandler
Sub update() dim t as String dim sock as tcpSocket if s<>Nil then sock=new tcpSocket t="IP "+sock.LocalAddress if t<>last then s.Title=t last=t end if end if End Sub
Property c As clock
Property last As string
Property s As NSStatusItemMBS
End Class
Class Clock Inherits Timer
EventHandler Sub Action() app.update End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCocoa Plugin.





Links
MBS Xojo tutorial videos