Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/DatePicker


Required plugins for this example: MBS MacFrameworks Plugin, MBS MacBase Plugin, MBS MacControls 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: /MacControls/DatePicker

This example is the version from Wed, 30th Oct 2018.

Project "DatePicker.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control CocoaControlMBS1 Inherits CocoaControlMBS
ControlInstance CocoaControlMBS1 Inherits CocoaControlMBS
EventHandler Function GetView() As NSViewMBS n1=new MyNSDatePickerMBS(0,0,me.Width,me.Height) n1.datePickerStyle = NSDatePickerMBS.NSTextFieldAndStepperDatePickerStyle n1.datePickerMode = NSDatePickerMBS.NSSingleDateMode // just date n1.datePickerElements = NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag 'n1.backgroundColor = NSColorMBS.whiteColor n1.drawsBackground = true Return n1 End EventHandler
End Control
Control CocoaControlMBS2 Inherits CocoaControlMBS
ControlInstance CocoaControlMBS2 Inherits CocoaControlMBS
EventHandler Function GetView() As NSViewMBS n3=new MyNSDatePickerMBS(0,0,me.Width,me.Height) n3.datePickerStyle = NSDatePickerMBS.NSTextFieldAndStepperDatePickerStyle n3.datePickerMode = NSDatePickerMBS.NSSingleDateMode // date and time n3.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag + NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag 'n3.backgroundColor = NSColorMBS.whiteColor n3.drawsBackground = true Return n3 End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control CocoaControlMBS3 Inherits CocoaControlMBS
ControlInstance CocoaControlMBS3 Inherits CocoaControlMBS
EventHandler Function GetView() As NSViewMBS n2=new MyNSDatePickerMBS(0,0,me.Width,me.Height) n2.datePickerStyle = NSDatePickerMBS.NSTextFieldAndStepperDatePickerStyle n2.datePickerMode = NSDatePickerMBS.NSSingleDateMode // just time n2.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag 'n2.backgroundColor = NSColorMBS.whiteColor n2.drawsBackground = true Return n2 End EventHandler
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control SetButton Inherits PushButton
ControlInstance SetButton Inherits PushButton
EventHandler Sub Action() dim now as new date n1.DateValue = now n2.DateValue = now n3.DateValue = now n4.DateValue = now n5.DateValue = now End EventHandler
End Control
Control CocoaControlMBS4 Inherits CocoaControlMBS
ControlInstance CocoaControlMBS4 Inherits CocoaControlMBS
EventHandler Function GetView() As NSViewMBS n5=new MyNSDatePickerMBS(0,0,me.Width,me.Height) n5.datePickerStyle = NSDatePickerMBS.NSClockAndCalendarDatePickerStyle n5.datePickerMode = NSDatePickerMBS.NSSingleDateMode // just date n5.datePickerElements = NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag 'n5.backgroundColor = NSColorMBS.whiteColor n5.drawsBackground = true Return n5 End EventHandler
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control CocoaControlMBS5 Inherits CocoaControlMBS
ControlInstance CocoaControlMBS5 Inherits CocoaControlMBS
EventHandler Function GetView() As NSViewMBS n4=new MyNSDatePickerMBS(0,0,me.Width,me.Height) n4.datePickerStyle = NSDatePickerMBS.NSClockAndCalendarDatePickerStyle n4.datePickerMode = NSDatePickerMBS.NSSingleDateMode n4.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag // date and time n4.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag + NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag 'n4.backgroundColor = NSColorMBS.whiteColor n4.drawsBackground = true Return n4 End EventHandler
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control QueryButton Inherits PushButton
ControlInstance QueryButton Inherits PushButton
EventHandler Sub Action() dim d1 as date = n1.DateValue dim d2 as date = n2.DateValue dim d3 as date = n3.DateValue dim d4 as date = n4.DateValue dim d5 as date = n5.DateValue MsgBox _ d1.LongDate+" "+d1.LongTime+EndOfLine+_ d2.LongDate+" "+d2.LongTime+EndOfLine+_ d3.LongDate+" "+d3.LongTime+EndOfLine+_ d4.LongDate+" "+d4.LongTime+EndOfLine+_ d5.LongDate+" "+d5.LongTime End EventHandler
End Control
Control Status Inherits Label
ControlInstance Status Inherits Label
End Control
EventHandler Sub Open() if not CocoaControlMBS1.Available then MsgBox "This example requires Mac OS X 10.5." quit end if End EventHandler
Property n1 As NSDatePickerMBS
Property n2 As NSDatePickerMBS
Property n3 As NSDatePickerMBS
Property n4 As NSDatePickerMBS
Property n5 As NSDatePickerMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyNSDatePickerMBS Inherits NSDatePickerMBS
EventHandler Sub Action() dim d1 as date = me.DateValue window1.Status.Text = d1.LongDate+" "+d1.LongTime End EventHandler
End Class
End Project

See also:

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


The biggest plugin in space...