23
calendar.go
23
calendar.go
@@ -16,7 +16,7 @@ type Calendar struct {
|
||||
monthLabel *Label
|
||||
|
||||
on struct {
|
||||
edit event.FuncBroadcaster
|
||||
valueChange event.FuncBroadcaster
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ func NewCalendar (tm time.Time) *Calendar {
|
||||
prevButton.SetIcon(tomo.IconGoPrevious)
|
||||
prevButton.OnClick(func () {
|
||||
calendar.prevMonth()
|
||||
calendar.on.edit.Broadcast()
|
||||
calendar.on.valueChange.Broadcast()
|
||||
})
|
||||
nextButton := NewButton("")
|
||||
nextButton.SetIcon(tomo.IconGoNext)
|
||||
nextButton.OnClick(func () {
|
||||
calendar.nextMonth()
|
||||
calendar.on.edit.Broadcast()
|
||||
calendar.on.valueChange.Broadcast()
|
||||
})
|
||||
calendar.monthLabel = NewLabel("")
|
||||
calendar.monthLabel.SetAlign(tomo.AlignMiddle, tomo.AlignMiddle)
|
||||
@@ -60,17 +60,22 @@ func NewCalendar (tm time.Time) *Calendar {
|
||||
return calendar
|
||||
}
|
||||
|
||||
// SetTime sets the date the calendar will display.
|
||||
func (this *Calendar) SetTime (tm time.Time) {
|
||||
// Value returns the time this calendar is displaying.
|
||||
func (this *Calendar) Value () time.Time {
|
||||
return this.time
|
||||
}
|
||||
|
||||
// SetValue sets the date the calendar will display.
|
||||
func (this *Calendar) SetValue (tm time.Time) {
|
||||
if this.time == tm { return }
|
||||
this.time = tm
|
||||
this.refresh()
|
||||
}
|
||||
|
||||
// OnEdit sets a function to be called when the user changes the date on the
|
||||
// calendar.
|
||||
func (this *Calendar) OnEdit (callback func ()) {
|
||||
this.on.edit.Connect(callback)
|
||||
// OnValueChange sets a function to be called when the user changes the date on
|
||||
// the calendar.
|
||||
func (this *Calendar) OnValueChange (callback func ()) {
|
||||
this.on.valueChange.Connect(callback)
|
||||
}
|
||||
|
||||
func (this *Calendar) prevMonth () {
|
||||
|
||||
Reference in New Issue
Block a user