Serious bugs in sMonthCalendar

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #36972
    HeDiBo
    Participant

    This picture shows three stages of clicking a date in the next month (clicking June 4 in the May calendar):

    [attachment=7705:CalendarBug.jpg]

    The blue circle shows where the cursor is during this.

    The cursor rests on June 4 in picture 1.

    Clicking June 4 results in picture 2: the highlight is on June 4 but the cursor is now on July 9 (because it didn't move to the new highlight).

    Releasing the button results in picture 3: the highlight has moved to July 9.

    So if you click on a day that will change the month, things go haywire.

    Second problem: neither OnMouseUp nor OnMouseDown are fired :a1:

    #55014
    HeDiBo
    Participant

    When OnMouseUp and OnMouseDown work, there should be an easy way to get from the X,Y coordinates to the pertinent date.

    #55016
    Ronaldo Souza
    Participant
    'HeDiBo' wrote:

    When OnMouseUp and OnMouseDown work, there should be an easy way to get from the X,Y coordinates to the pertinent date.

    I believe you can use the day, month & year fieds to get the current date:

    procedure TForm1.sMonthCalendar1Change(Sender: TObject); //OnChange handler

    begin

    Form1.Caption := Format('%0.2d/%0.2d/%0.2d',[sMonthCalendar1.day,sMonthCalendar1.month,sMonthCalendar1.year]);

    end;

    Hope it helps!

    Best regards,

    Ronaldo

    #55018
    HeDiBo
    Participant
    'Ronaldo wrote:

    I believe you can use the day, month & year fieds to get the current date:

    Thank you for your efforts. Much appreciated.

    In the OnMouseUp and OnMouseDown event the X and Y coordinates in the parameters do not reflect the current date. Clicking on a date with the right mouse button means the current day, month and year properties are not updated to the mouse position so only X and Y are the values usable. Therefore there should be an easy way to get from (X,Y) to the date clicked.

    #55022
    Support
    Keymaster

    Hi!

    I see this problem and I will solve it in the nearest release, thanks for the messages.

    #55080
    HeDiBo
    Participant
    'Support' wrote:

    Hi!

    I see this problem and I will solve it in the nearest release, thanks for the messages.

    I am very sorry to finding out that you corrected this bug in the beta release 11 but not in the stable release 10.

    #55083
    Support
    Keymaster

    I have added changes into the v10 also. I hope to release the v10.30 soon.

    #55098
    HeDiBo
    Participant
    'Support' wrote:

    I have added changes into the v10 also. I hope to release the v10.30 soon.

    Great, thanks :a3:

    Will that also include function(s) to get from the X and Y coordinates of OnMouseUp and OnMouseDown to cell coordinates and then to date?

    I want to implement a right click event in a calendar, much like the OnDblClick event.

    #55106
    Support
    Keymaster

    Ok, the MousePosToDate function will be added )

    #55116
    HeDiBo
    Participant
    'Support' wrote:

    Ok, the MousePosToDate function will be added )

    Maybe it should be done in two functions:

    MouseToCell from the underlying TsCalendarGrid is already there. All we need therefore is CellToDate. For that all you have to do is make the private function GetCellDate part of a new property “CellDate” (a read-only property). That was probably your plan from the beginning, considering the analog CellText property.

    #55124
    Support
    Keymaster

    Hi!

    The protected GetCellDate function exists there, I can move it to the “public”:

    Code:
    function GetCellDate(ACol, ARow: Integer): TDateTime;
    #55131
    HeDiBo
    Participant
    'Support' wrote:

    Hi!

    The protected GetCellDate function exists there, I can move it to the “public”:

    Code:
    function GetCellDate(ACol, ARow: Integer): TDateTime;

    You already have this public property:

    Code:
    property CellText[ACol, ARow: Integer]: string read GetCellText;

    So, analogous, you could add this:

    Code:
    property CellDate[ACol, ARow: Integer]: TDateTime read GetCellDate;

    Looks even better, don't you think?

    #55140
    Support
    Keymaster

    Yes, you are right, CellDate will be added.

    #55154
    HeDiBo
    Participant
    'Support' wrote:

    Yes, you are right, CellDate will be added.

    I edited my post, because it returned a String i.s.o. a TDateTime

    #55163
    HeDiBo
    Participant

    Function MousePosToDate works like a charm :a3:.

    The property CellDate should produce the same result. But because the caller does not know about the grid's borders, it is a week off. I think it could be removed again, because it serves no purpose this way.

    See what I mean in this project: [attachment=7739:acCalendarMouseUp.zip]

    #55166
    HeDiBo
    Participant

    To my dismay, now DoubleClick doesn't work anymore 😡

    If OnMouseUp is defined, it does not fire (which is standard behavior), but…

    if OnMouseUp is undefined, it fires TWO TIMES!

    The problem is in this definition:

    Code:
    TsCalendGrid = class(TDrawGrid)
    private
    FOwner: TsMonthCalendar;
    procedure WMSize (var Message: TWMSize ); message WM_SIZE;
    procedure WMMouseActivate(var Message: TMessage); message WM_MOUSEACTIVATE;
    protected
    procedure WndProc(var Message: TMessage); override;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure MouseUp (Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure DblClick; override; // This should be removed again: double click already works on the owning TsMonthCalendar
    public
    #55169
    Support
    Keymaster
Viewing 17 posts - 1 through 17 (of 17 total)
  • You must be logged in to reply to this topic.