Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/DatePicker control
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/DatePicker control
This example is the version from Fri, 22th Jan 2015.
Project "DatePicker control.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Picker1 Inherits NSDatePickerControlMBS
ControlInstance Picker1 Inherits NSDatePickerControlMBS
EventHandler Sub Action() dim d1 as date = me.view.DateValue window1.Status.Text = d1.LongDate+" "+d1.LongTime End EventHandler
EventHandler Sub Open() n1 = picker1.View n1.datePickerStyle = NSDatePickerMBS.NSTextFieldAndStepperDatePickerStyle n1.datePickerMode = NSDatePickerMBS.NSSingleDateMode // just date n1.datePickerElements = NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag n1.backgroundColor = NSColorMBS.whiteColor n1.drawsBackground = true End EventHandler
End Control
Control Picker2 Inherits NSDatePickerControlMBS
ControlInstance Picker2 Inherits NSDatePickerControlMBS
EventHandler Sub Action() dim d1 as date = me.view.DateValue window1.Status.Text = d1.LongDate+" "+d1.LongTime End EventHandler
EventHandler Sub Open() n2 = picker2.View n2.datePickerStyle = NSDatePickerMBS.NSTextFieldAndStepperDatePickerStyle n2.datePickerMode = NSDatePickerMBS.NSSingleDateMode // just time n2.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag n2.backgroundColor = NSColorMBS.whiteColor n2.drawsBackground = true 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 Picker3 Inherits NSDatePickerControlMBS
ControlInstance Picker3 Inherits NSDatePickerControlMBS
EventHandler Sub Action() dim d1 as date = me.view.DateValue window1.Status.Text = d1.LongDate+" "+d1.LongTime End EventHandler
EventHandler Sub Open() n3 = picker3.View n3.datePickerStyle = NSDatePickerMBS.NSTextFieldAndStepperDatePickerStyle n3.datePickerMode = NSDatePickerMBS.NSSingleDateMode // date and time n3.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag + NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag n3.backgroundColor = NSColorMBS.whiteColor n3.drawsBackground = true 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 Picker4 Inherits NSDatePickerControlMBS
ControlInstance Picker4 Inherits NSDatePickerControlMBS
EventHandler Sub Action() dim d1 as date = me.view.DateValue window1.Status.Text = d1.LongDate+" "+d1.LongTime End EventHandler
EventHandler Sub Open() n4 = picker4.View n4.datePickerStyle = NSDatePickerMBS.NSClockAndCalendarDatePickerStyle n4.datePickerMode = NSDatePickerMBS.NSSingleDateMode // just date n4.datePickerElements = NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag n4.backgroundColor = NSColorMBS.whiteColor n4.drawsBackground = true End EventHandler
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control Picker5 Inherits NSDatePickerControlMBS
ControlInstance Picker5 Inherits NSDatePickerControlMBS
EventHandler Sub Action() dim d1 as date = me.view.DateValue window1.Status.Text = d1.LongDate+" "+d1.LongTime End EventHandler
EventHandler Sub Open() n5 = picker5.View n5.datePickerStyle = NSDatePickerMBS.NSClockAndCalendarDatePickerStyle n5.datePickerMode = NSDatePickerMBS.NSSingleDateMode n5.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag // date and time n5.datePickerElements = NSDatePickerMBS.NSHourMinuteSecondDatePickerElementFlag + NSDatePickerMBS.NSYearMonthDayDatePickerElementFlag n5.backgroundColor = NSColorMBS.whiteColor n5.drawsBackground = true 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 TargetCocoa 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
End Project

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo Chart Plugins