Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DatePicker Visual Library
Message
From
20/09/2018 22:33:03
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
 
To
20/09/2018 13:50:13
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01662041
Message ID:
01662179
Views:
70
Antonio, work to date: this allows navigation in calendar using arrow keys, pageup/down, home for first of month, Ctrl+home =today, T or t to edit time, and also enter=set date, Esc or Alt+f4=Exit without saving

I investigated doing a mousewheel to scroll up/down as well, but it appears you'd need to bindevent mousewheel for every element, which seems excessive! The alternative would be to create new shape/label classes in the class library and add those instead of generic shapes/labels, which allows mousewheel in the objects. Will think about this. Meanwhile:

In Formdatepicker class:

- Keypreview=.t.

Formdatepicker.Keypress event:
Lparameters nKeyCode, nShiftAltCtrl

Do Case

Case m.nKeyCode=27 Or m.nKeyCode=107 And m.nShiftAltCtrl=4	&&escape, Alt F4
	Nodefault
	Thisform.Release()

Case m.nKeyCode=13 And m.nShiftAltCtrl=0 Or m.nKeyCode=10 And m.nShiftAltCtrl=2	&&enter or Ctrl+enter
	This.SetDate(This.SelectedDate)

CASE thisform.pgfViews.ActivePage=4	&&doing time, so need arrows to work
	DoDefault(m.nKeyCode,m.nShiftAltCtrl)
		
Case m.nKeyCode=5 And m.nShiftAltCtrl=0	&&Up Arrow
	Nodefault
	This.movereference(-7,-4,-48)

Case m.nKeyCode=24 And m.nShiftAltCtrl=0	&&Down Arrow
	Nodefault
	This.movereference(7,4,48)

Case m.nKeyCode=19 And m.nShiftAltCtrl=0	&&left arrow
	Nodefault
	This.movereference(-1,-1,-12)

Case m.nKeyCode=4 And m.nShiftAltCtrl=0	&&right arrow
	Nodefault
	This.movereference(1,1,12)

Case m.nKeyCode=18 And m.nShiftAltCtrl=0	&&pageup
	Nodefault
	This.movereference(-99,-12,-144)

Case m.nKeyCode=3 And m.nShiftAltCtrl=0	&&pagedown
	Nodefault
	This.movereference(99,12,144)

Case m.nKeyCode=1 And m.nShiftAltCtrl=0	&&home: go to first day of month
	This.SelectedDate=This.SelectedDate-Day(This.SelectedDate)+1
	This.movereference(0,0,0)

Case m.nKeyCode=29 And m.nShiftAltCtrl=2 &&Ctrl+Home=today
	Nodefault
	This.SelectedDate=Date()
	This.movereference(0,0,0)

Case m.nKeyCode=116 And m.nShiftAltCtrl=0 ;
		OR 	m.nKeyCode=84 And m.nShiftAltCtrl=1	&& t or T = time
	IF this.lblSelectedTime.visible
		*---only if time enabled!
		NODEFAULT
		this.lblSelectedTime.Click()
	ENDIF
	
Otherwise
	DoDefault(m.nKeyCode,m.nShiftAltCtrl)
Endcase
New method Formdatepicker.MoveReference:
LPARAMETERS m.lnday,m.lnmonth,m.lnYear

DO CASE

CASE Thisform.pgfViews.ActivePage = Thisform.pgfViews.pagDays.PageOrder
	
	IF ABS(m.lnday)<99
		Thisform.selecteddate = Thisform.selecteddate+m.lnDay
	ELSE
		*---99 means move a month
		Thisform.selecteddate = Thisform.MoveDate(Thisform.selecteddate,IIF(m.lnday<0,-1,1))
	ENDIF
	thisform.referencedate=Thisform.selecteddate
	Thisform.PopulateDays()	

CASE Thisform.pgfViews.ActivePage = Thisform.pgfViews.pagMonths.PageOrder
	Thisform.selecteddate = Thisform.MoveDate(Thisform.selecteddate,m.lnmonth)
	thisform.referencedate=Thisform.selecteddate
	Thisform.PopulateMonths()

CASE Thisform.pgfViews.ActivePage = Thisform.pgfViews.pagYears.PageOrder
	Thisform.selecteddate = Thisform.MoveDate(Thisform.selecteddate,m.lnyear)
	thisform.referencedate=Thisform.selecteddate
	Thisform.PopulateYears()
endcase
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform