Grid : EndLabelEdit event : trigger lag

Started by krunch, March 13, 2012, 01:34:30 PM

Previous topic - Next topic

krunch

Hi

I have a grid with following column styles : 3 31 33 32 22

Is it normal that OnEndLabelEdit triggers

Fred Tomke

Hi, krunch, yes, of course. Maybe a better name would be OnEndCellEdit: it is fired if you have finished or cancelled the editing state of the cell - does not depend on the style.
I've just explained it by myself this way: the start of the cell editing state (OnBeginLabelEdit) means that an other control is shown instead of the cell. It is generated at runtime. You change a value and after leaving the focus off the internal control it disappears and the result is written into the cell (OnEndLabelEdit). Colors, images and so on are drawn within an OnPaint-event and overrides the pure text cellstyles. That's the way I explain it to myself - not knowing if the grid does work this way. Somewhere in this forum I've posted a sample working with Enter and ESC in grids.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

krunch

Hi

Sorry I had not seen that this message has been posted : it's not finished !
It was about the event lag, and I wanted to join a sample ..

As you said EndLabelEdit is triggered only when you leave the column (not after it's changed), moreover it seems to miss 1 click with the image swap (style 3) ..
I will make a sample later.

Regards

Fred Tomke

H, have a look here. There you can see how to manage OnEndLabelEdit after pressing Enter in a grid.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

krunch

Hi

Ok I've read, but I don't have this problem with Enter (no text input).


QuoteYou change a value and after leaving the focus off the internal control
So there's no way to get a triggering just after the user has changed a value (for example with style 33 32 22), I have to click in another column to validate ?

QuoteColors, images and so on are drawn within an OnPaint-event and overrides the pure text cellstyles.
I don't understand this (there's no OnPaint event).
My problem (style 3) is that the event OnEndLabelEdit doesn't triggers on 1st click while the image is switched, so I get an inversion of the state (on/off images)

Regards

Fred Tomke

Hi,
after you've changed a value and the grid's drop down has been collapsed, the OnMouseMove event will be fired (if you have activated it).
So my guess is to activate the OnMouseMove event within OnStartLabelEdit event and remove it at the first call of the OnMouseMove event function and call CancelLabelEdit. I've done this, too because I don't like it when the user has changed the grid's cell with checkbox style but the next time OnEndLabelEdit will be fired will be when the user clicks on an other cell.

Code (autolisp) Select

(defun c:proj_form_grid_OnStartLabelEdit  (nRow nCol)
  (setq lstLabelEdit (list nRow nCol (dcl_Grid_GetCellText proj_form_grid nRow nCol)))
  (dcl_Control_SetProperty proj_form_grid "MouseMove" "c:proj_form_grid_OnMouseMove")
); c:proj_form_grid_OnStartLabelEdit

(defun c:proj_form_grid_OnMouseMove (intFlags  intX intY)
  (dcl_Control_SetProperty proj_form_grid "MouseMove" "")
  (if lstLabelEdit (dcl_Grid_CancelCellEdit proj_form_grid))
); c:proj_form_grid_OnMouseMove

(defun c:proj_form_grid_OnEndLabelEdit  (nRow nCol)
  (if lstLabelEdit 
    (progn
      ;; do something     
      (if (/= (dcl_Control_GetProperty proj_form_grid "MouseMove") "")
        (dcl_Control_SetProperty proj_form_grid "MouseMove" "")
      ); if
      (setq lstLabelEdit nil)
    ); progn
  ); if
); c:proj_form_grid_OnEndLabelEdit


Hope that helps.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

krunch

Hi

Thanks for this solution, it improves the behavior (with the following changes)

Code (autolisp) Select
(defun c:proj_form_grid_OnBeginLabelEdit  (nRow nCol) 
  (setq lstLabelEdit T)
  (dcl_Control_SetProperty proj_form_grid "MouseMove" "c:proj_form_grid_OnMouseMove") 
); c:proj_form_grid_OnStartLabelEdit 


For me it removes my problem with style=3, and the comboboxes need 1 click less to pass from one to other (example bellow), so it's lighter. If the Form had a onMouseMove event it would be perfect...

-----------------
I post a sample with the problem I had with OnEndLabelEdit .. In this example when you change a property in the first grid (line) the 2nd grid is updated with same.
OnEndLabelEdit doesn't detects the 1st click onto the on/off image (while the images are switched) so the state is inverted...

Other thing : comboboxes (linetype stylename) need 3 clicks to unfold when I pass from one to the other, so it's a little bit heavy

Thanks

Regards

Fred Tomke

Hi, I didn't had the time to have a look. I will need some days to find free time to have a look at it.
Sorry.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

krunch

Hi

Here is a little code that improves reactivity of grids, especially with controls like combo boxes.
It selects directly the cell under the pointer, so you can see it, and it avoids 1 click to pass from one to another

Note that SetCurCell triggers OnEndLabelEdit, so it can replace your code below
Regards

Code (autolisp) Select
(defun c:proj_form_grid_OnMouseMove (Flags X Y / cell) 
    (setq cell (dcl_Grid_HitPointTest proj_form_grid X Y))
    (dcl_Grid_SetCurCell proj_form_grid (car cell) (cadr cell))
)

Fred Tomke

Hi, nice idea. I would recommend to test if the cell isn't currently already active before using SetCurCell method. Please note that OnMouseMove will be catched every little pixel you move the mouse.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

krunch

#10
Good, the test eliminates the blinking effect

Code (autolisp) Select
(defun c:proj_form_grid_OnMouseMove (Flags X Y / cell)
   (setq cell (dcl_Grid_HitPointTest proj_form_grid X Y)
            X (car cell)
            Y (cadr cell))
   (or (equal cell (dcl_Grid_GetCurCell proj_form_grid))
        (dcl_Grid_SetCurCell proj_form_grid X Y)
   )
)



And here to filter columns you don't want to select (columnstyle = 0)

Code (autolisp) Select
(defun c:proj_form_grid_OnMouseMove (Flags X Y / cell)
   (setq cell (dcl_Grid_HitPointTest proj_form_grid X Y)
   (or (equal cell (dcl_Grid_GetCurCell proj_form_grid))
        (member (setq X (car cell) Y (cadr cell)) '(1)) ; column #1 is read only
        (dcl_Grid_SetCurCell proj_form_grid X Y)
   )
)