diff --git a/components/tvplanit/source/vpdayview.pas b/components/tvplanit/source/vpdayview.pas index cea9e3b3b..d55e1beee 100644 --- a/components/tvplanit/source/vpdayview.pas +++ b/components/tvplanit/source/vpdayview.pas @@ -240,6 +240,7 @@ type FHintMode: TVpHintMode; FIconAttributes: TVpDayViewIconAttributes; FIncludeWeekends: Boolean; + FKBNavigate: Boolean; FLineColor: TColor; FLineCount: Integer; FMouseEvent: TVpEvent; @@ -518,6 +519,7 @@ type property NumDays: Integer read FNumDays write SetNumDays default 1; property WrapStyle: TVpDVWrapStyle read FWrapStyle Write SetWrapStyle default wsIconFlow; property HintMode: TVpHintMode read FHintMode write SetHintMode default hmPlannerHint; + property KBNavigation: Boolean read FKBNavigate write FKBNavigate default true; property ShowNavButtons: Boolean read FShowNavButtons write SetShowNavButtons default true; property FixedDate: Boolean read FFixedDate write FFixedDate default false; property RowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0; @@ -808,6 +810,7 @@ begin FIncludeWeekends := True; FAllowInplaceEdit := true; FShowEventTimes := true; + FKBNavigate := true; { set up fonts and colors } FHeadAttr.Font.Size := 10; @@ -2362,60 +2365,65 @@ procedure TVpDayView.KeyDown(var Key: Word; Shift: TShiftState); var PopupPoint : TPoint; begin - case Key of - VK_UP: - ActiveRow := ActiveRow - 1; - VK_DOWN: - ActiveRow := ActiveRow + 1; - VK_NEXT: - ActiveRow := ActiveRow + FVisibleLines; - VK_PRIOR: - ActiveRow := ActiveRow - FVisibleLines; - VK_LEFT: - Date := Date - 1; - VK_RIGHT: - Date := Date + 1; - VK_HOME: - ActiveRow := 0; - VK_END: - ActiveRow := LineCount; - VK_DELETE: - if not ReadOnly then - DeleteActiveEvent(true); -{$IFNDEF LCL} - VK_TAB: - if ssShift in Shift then - Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, False)) - else - Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, True)); -{$ENDIF} - VK_F10: - if (ssShift in Shift) and not (Assigned (PopupMenu)) then begin - PopupPoint := GetClientOrigin; - FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); - end; - VK_APPS : - if not Assigned(PopupMenu) then begin - PopupPoint := GetClientOrigin; - FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); - end; - VK_RETURN: - PopupEditEvent(Self); - VK_INSERT: - PopupAddEvent(Self); - VK_F2: - if Assigned(FActiveEvent) then - dvEditInPlace(Self) - else - begin - PopupPoint := dvLineMatrix[ActiveCol, ActiveRow].Rec.TopLeft; - PopupPoint.x := PopupPoint.x + 1; - PopupPoint.y := PopupPoint.y + 1; - SetActiveEventByCoord (PopupPoint); + if FKBNavigate then + case Key of + VK_UP: + ActiveRow := ActiveRow - 1; + VK_DOWN: + ActiveRow := ActiveRow + 1; + VK_NEXT: + ActiveRow := ActiveRow + FVisibleLines; + VK_PRIOR: + ActiveRow := ActiveRow - FVisibleLines; + VK_LEFT: + Date := Date - 1; + VK_RIGHT: + Date := Date + 1; + VK_HOME: + ActiveRow := 0; + VK_END: + ActiveRow := LineCount; + VK_DELETE: + if not ReadOnly then + DeleteActiveEvent(true); + {$IFNDEF LCL} + VK_TAB: + if ssShift in Shift then + Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, False)) + else + Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, True)); + {$ENDIF} + VK_F10: + if (ssShift in Shift) and not (Assigned (PopupMenu)) then begin + PopupPoint := GetClientOrigin; + FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); + end; + VK_APPS : + if not Assigned(PopupMenu) then begin + PopupPoint := GetClientOrigin; + FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); + end; + VK_RETURN: + PopupEditEvent(Self); + VK_INSERT: + PopupAddEvent(Self); + VK_F2: if Assigned(FActiveEvent) then - dvEditInPlace(Self); - end; - end; + dvEditInPlace(Self) + else + begin + PopupPoint := dvLineMatrix[ActiveCol, ActiveRow].Rec.TopLeft; + PopupPoint.x := PopupPoint.x + 1; + PopupPoint.y := PopupPoint.y + 1; + SetActiveEventByCoord (PopupPoint); + if Assigned(FActiveEvent) then + dvEditInPlace(Self); + end; + end + else + Key := 0; + + inherited; end; {$IFNDEF LCL} diff --git a/components/tvplanit/source/vpmonthview.pas b/components/tvplanit/source/vpmonthview.pas index 59c2c4ae8..67bb85e81 100644 --- a/components/tvplanit/source/vpmonthview.pas +++ b/components/tvplanit/source/vpmonthview.pas @@ -1495,7 +1495,11 @@ begin PopupPoint := GetClientOrigin; FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); end; - end; + end + else + Key := 0; + + inherited; end; procedure TVpMonthView.MouseDown(Button: TMouseButton; Shift: TShiftState; diff --git a/components/tvplanit/source/vpmonthviewpainter.pas b/components/tvplanit/source/vpmonthviewpainter.pas index 5033d282e..d6551324d 100644 --- a/components/tvplanit/source/vpmonthviewpainter.pas +++ b/components/tvplanit/source/vpmonthviewpainter.pas @@ -117,8 +117,6 @@ begin todayDate := Date(); DecodeDate(ADate, Y, M, D); - WriteLn(ATextRect.Top, ', ', ATextRect.Bottom, ', ', RealBottom); - if (ACol = 6) then ATextRect.Right := ATextRect.Right + 8; diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index dc303d29c..10c55363c 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -157,6 +157,7 @@ type FHeadAttr: TVpWvHeadAttributes; FHeaderMargin: Integer; FHintMode: TVpHintMode; + FKBNavigate: Boolean; FLineColor: TColor; FMouseEvent: TVpEvent; FLayout: TVpWeekviewLayout; @@ -353,6 +354,7 @@ type property HeadAttributes: TVpWvHeadAttributes read FHeadAttr write FHeadAttr; property HeaderMargin: Integer read FHeaderMargin write SetHeaderMargin default TEXT_MARGIN; property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint; + property KBNavigation: Boolean read FKBNavigate write FKBNavigate default true; property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR; property Layout: TVpWeekviewLayout read FLayout write SetLayout default wvlVertical; property TextMargin: Integer read FTextMargin write SetTextMargin default 2; @@ -629,6 +631,7 @@ begin wvClickTimer.OnTimer := wvEditInPlace; wvCreatingEditor := false; FDrawingStyle := ds3d; + FKBNavigate := true; wvPainting := false; FColor := DEFAULT_COLOR; FLineColor := DEFAULT_LINECOLOR; @@ -1801,89 +1804,94 @@ procedure TVpWeekView.KeyDown(var Key: Word; Shift: TShiftState); var PopupPoint : TPoint; begin - case Key of - VK_DELETE : DeleteActiveEvent(true); - VK_RIGHT : if Shift = [ssShift] then - PopupNextWeek (Self) - else if (Shift = [ssCtrl]) then - PopupNextMonth (Self) - else if (Shift = [ssShift, ssCtrl]) then - PopupNextYear (Self) - else if Shift = [] then begin - case DayOfWeek (FActiveDate) of - 1 : FActiveDate := FActiveDate - 4; - 2 : FActiveDate := FActiveDate + 3; - 3 : FActiveDate := FActiveDate + 3; - 4 : FActiveDate := FActiveDate + 3; - 5 : FActiveDate := FActiveDate - 3; - 6 : FActiveDate := FActiveDate - 3; - 7 : FActiveDate := FActiveDate - 3; - end; - Invalidate; - end; - VK_LEFT : if Shift = [ssShift] then - PopupPrevWeek (Self) - else if (Shift = [ssCtrl]) then - PopupPrevMonth (Self) - else if (Shift = [ssShift, ssCtrl]) then - PopupPrevYear (Self) - else if Shift = [] then begin - case DayOfWeek (FActiveDate) of - 1 : FActiveDate := FActiveDate - 4; - 2 : FActiveDate := FActiveDate + 3; - 3 : FActiveDate := FActiveDate + 3; - 4 : FActiveDate := FActiveDate + 3; - 5 : FActiveDate := FActiveDate - 3; - 6 : FActiveDate := FActiveDate - 3; - 7 : FActiveDate := FActiveDate - 3; - end; - Invalidate; - end; - VK_UP : begin - if Shift = [] then + if FKBNavigate then + case Key of + VK_DELETE : DeleteActiveEvent(true); + VK_RIGHT : if Shift = [ssShift] then + PopupNextWeek (Self) + else if (Shift = [ssCtrl]) then + PopupNextMonth (Self) + else if (Shift = [ssShift, ssCtrl]) then + PopupNextYear (Self) + else if Shift = [] then begin case DayOfWeek (FActiveDate) of - 1 : FActiveDate := FActiveDate - 1; - 2 : FActiveDate := FActiveDate + 2; - 3 : FActiveDate := FActiveDate - 1; - 4 : FActiveDate := FActiveDate - 1; - 5 : FActiveDate := FActiveDate + 3; - 6 : FActiveDate := FActiveDate - 1; - 7 : FActiveDate := FActiveDate - 1; + 1 : FActiveDate := FActiveDate - 4; + 2 : FActiveDate := FActiveDate + 3; + 3 : FActiveDate := FActiveDate + 3; + 4 : FActiveDate := FActiveDate + 3; + 5 : FActiveDate := FActiveDate - 3; + 6 : FActiveDate := FActiveDate - 3; + 7 : FActiveDate := FActiveDate - 3; end; - Invalidate; - end; - VK_DOWN : begin - if Shift = [] then + Invalidate; + end; + VK_LEFT : if Shift = [ssShift] then + PopupPrevWeek (Self) + else if (Shift = [ssCtrl]) then + PopupPrevMonth (Self) + else if (Shift = [ssShift, ssCtrl]) then + PopupPrevYear (Self) + else if Shift = [] then begin case DayOfWeek (FActiveDate) of - 1 : FActiveDate := FActiveDate - 3; - 2 : FActiveDate := FActiveDate + 1; - 3 : FActiveDate := FActiveDate + 1; - 4 : FActiveDate := FActiveDate - 2; - 5 : FActiveDate := FActiveDate + 1; - 6 : FActiveDate := FActiveDate + 1; - 7 : FActiveDate := FActiveDate + 1; + 1 : FActiveDate := FActiveDate - 4; + 2 : FActiveDate := FActiveDate + 3; + 3 : FActiveDate := FActiveDate + 3; + 4 : FActiveDate := FActiveDate + 3; + 5 : FActiveDate := FActiveDate - 3; + 6 : FActiveDate := FActiveDate - 3; + 7 : FActiveDate := FActiveDate - 3; end; - Invalidate; - end; - VK_INSERT : PopupAddEvent(Self); -{$IFNDEF LCL} - VK_TAB : - if ssShift in Shift then - Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False)) - else - Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True)); -{$ENDIF} - VK_F10: - if (ssShift in Shift) and not Assigned(PopupMenu) then begin - PopupPoint := GetClientOrigin; - FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); - end; - VK_APPS: - if not Assigned (PopupMenu) then begin - PopupPoint := GetClientOrigin; - FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); - end; - end; + Invalidate; + end; + VK_UP : begin + if Shift = [] then + case DayOfWeek (FActiveDate) of + 1 : FActiveDate := FActiveDate - 1; + 2 : FActiveDate := FActiveDate + 2; + 3 : FActiveDate := FActiveDate - 1; + 4 : FActiveDate := FActiveDate - 1; + 5 : FActiveDate := FActiveDate + 3; + 6 : FActiveDate := FActiveDate - 1; + 7 : FActiveDate := FActiveDate - 1; + end; + Invalidate; + end; + VK_DOWN : begin + if Shift = [] then + case DayOfWeek (FActiveDate) of + 1 : FActiveDate := FActiveDate - 3; + 2 : FActiveDate := FActiveDate + 1; + 3 : FActiveDate := FActiveDate + 1; + 4 : FActiveDate := FActiveDate - 2; + 5 : FActiveDate := FActiveDate + 1; + 6 : FActiveDate := FActiveDate + 1; + 7 : FActiveDate := FActiveDate + 1; + end; + Invalidate; + end; + VK_INSERT : PopupAddEvent(Self); + {$IFNDEF LCL} + VK_TAB : + if ssShift in Shift then + Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False)) + else + Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True)); + {$ENDIF} + VK_F10: + if (ssShift in Shift) and not Assigned(PopupMenu) then begin + PopupPoint := GetClientOrigin; + FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); + end; + VK_APPS: + if not Assigned (PopupMenu) then begin + PopupPoint := GetClientOrigin; + FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); + end; + end + else + Key := 0; + + inherited; end; procedure TVpWeekView.EndEdit(Sender: TObject);