Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1015
Confusion about event sequence
posted

I am trying to track the event sequence in an UltraGrid, but some of them don't make sense to me.

I have a form with a grid and an OK button (not on the grid). All I do is move the mouse to a cell, click on the cell, release the mouse button and then click the form's OK button. That's all, nothing more. The following sequence of events are recorded.

MouseEnter
Enter
GotFocus
LostFocus
ClickCell
MouseDown
MouseLeave
MouseEnter
MouseLeave
Leave

Some of these events make sense, but some don't. I am noting my thoughts on each event and the things I don't understand.

MouseEnter <- enters grid area
Enter <- enters cell
GotFocus <- cell focus
LostFocus <- Why does this happen? I didn't leave the cell!
ClickCell <- understood
MouseDown <- understood
MouseLeave <- Why does this happen? I didn't move the mouse out of the cell!

The above happens while the mouse is still in the cell. Now when I move the mouse to the OK button (carefully not moving the mouse near any other cell in the grid) the following happens:


MouseEnter <- Why? I didn't move the mouse near any other cell
MouseLeave <- same issue. Why?
Leave <- leaves gid area to go to OK button

And an additional thing: I specifically released the mouse button when I was in the cell, but the MouseUp event didn't fire. Why?

I'm using v10.2.

Thanks for helping me understand this.

  • 469350
    Offline posted

    Hi,

    MouseEnter and MouseLeave fire when the mouse moves into out of a control.

    I can't be sure, but my guess is that the cell you are clicking on it a normal edit cell and so when it goes into edit mode, the grid is displaying a TextBox control over the cell. Since the TextBox appears under the mouse, the mouse has essentially left the grid and entered the TextBox. Likewise, when you move the mouse off of the TextBox and over another cell (which is not in edit mode) you are re-entering the grid.

    This also explains the GotFocus and LostFocus. The grid loses focus to the TextBox control. Microsoft's documentation recommends against using GotFocus and LostFocus and instead using the Enter and Leave events for this very reason.

    sch said:
    And an additional thing: I specifically released the mouse button when I was in the cell, but the MouseUp event didn't fire. Why?

    The event went to the TextBox, not the grid.

    FAQ:Mouse events such as MouseDown, MouseUp, and DoubleClick do not fire when the mouse is over a cell that is in edit mode.