Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

ElXTree: Esc key when Inplace Editor is Editing: Doesn't return to original value unless invalid.

I expect the Escape key to be used to cancel an operation, and so do most users.

However, if the value in the Inplace editor has not failed the validity test already, then the value is not returned to the initial value (before editing began).

Is this something you would change?

How can I code to work around this?
That is, how can I change this behaviour so that the original value is returned when an active inplace editor receives the Escape key?

Raymond

Comments

  • 7 Comments sorted by Votes Date Added
  • I have tried the following work-arounds without success.

    1. Capture the Esc key on the form to control the outcome; KeyPreview := True.
        Form doesn't preview the Escape key.

    2. Added an Action to capture the Esc key to do the cancelling.
        InplaceEditor. Validate and AfterOperation are called before the Action is activated.

    3. Placed an OnKeyDown event handler on the InplaceEditor.Editor.
        The inplace editor does not receive the Esc key.

    Raymond
  • What data type and inplace editor do you use? I cannot reproduce the issue. When I press Esc while editing, the cell recieves value prior to editing start.
  • TElTreeInplaceDateTimePicker with Types: [sftDateTime], format: edfShortDateLongTime.

    I have validation and AfterAction tests for validity.

    If the validity and AfterActions tests for validity fail, the Esc returns the value to the original value.
    If it passes the tests then it keeps the current value.

    Raymond
  • Hello Victor. 

    I've discovered what's happening, and also what I believe could be a design issue.

    The TElTreeInplaceDateTimePicker has a Validation event and an AfterOperation event.

    The Validation event is not called if the Escape key is pressed.

    Because the AfterOperation event is called even if the Validation fails, my tests in AfterOperation set Accepted to True because the changed value is still acceptable.

    I am surprised the AfterOperation is called if I press Esc. 

    *** Why is this so?

    I have just checked what the value of Accepted is in AfterOperation if the Escape key is pressed and when the Validity check is passed. The former is False and the latter is True.

    Now I will test for Accepted being False and exit if so.

    This problem wouldn't have arisen if the online Help for the component explained what the parameter Accepted is used for and when it is set as either True or False and the consequences of setting it to True or False myself.

    Raymond


  • This issue is not resolved yet!

    If I make a change and then click outside of the inplace editor, then the changes are cancelled!!

    This causes Accepted to be False.

    This is unusual behaviour.

    What I need then is either 

    1. a way to determine in Validate and AfterOperation whether or not the user Escaped (cancelled) the operation; or

    2. a property AssumeAcceptedUnlessCancelled : Boolean that when True sets Accepted to True before calling the AfterOperation event and also calls the Validate event. When False, causes the same behaviour as pressing the Escape key currently has.

    An equivalent property could be CancelOnExit, which would have the reverse values of True/False to the 1st property name mentioned.

    or

    3. a unpublished property on the inplace editor that indicates whether the user pressed the Escape key or not.

    Would you implement one of these?

    Thanks.

    Raymond


  • What have you decided to do about this?

    Raymond
Sign In or Register to comment.