Page 1 of 1

Selection can't be cancelled by ESC

Posted: Wed Apr 19, 2023 1:35 am
by 16585294
On Windows, the standard behaviour of selection, dragging etc using the mouse is to cancel the operation if ESC is pressed.

This does not happen if I start creating a selection rectangle in a TChart. Pressing ESC does not cancel the operation.

Re: Selection can't be cancelled by ESC

Posted: Thu Apr 20, 2023 7:16 am
by Marc
Hello,

In general, if mouse interacttion with the chart is being used for other than just zoom/scroll, then Chart.CancelMouse can be set to deactivate a zoom-underway.

Ref. https://steema.com/docs/teechart/vclfmx ... Mouse.html

Code: Select all

// Tell the chart to do zoom or scroll as default:
Chart1.CancelMouse:=False;
Regards,
Marc

Re: Selection can't be cancelled by ESC

Posted: Sat Apr 22, 2023 3:32 am
by 16585294
My point is simply that the component does not adhere to standard Windows input behaviour in its default configuration.

Are you saying I should detect key presses manually during a rectangle selection, and set CancelMouse if ESC is pressed on the keyboard?

Re: Selection can't be cancelled by ESC

Posted: Fri May 12, 2023 6:31 am
by yeray
Hello,

You could use the OnKeyDown event to cancel the Zoom and Panning actions. Ie:

Code: Select all

procedure TForm1.Chart1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key=TeeKey_Escape then
  begin
    Chart1.Zoom.Active:=False;
    Chart1.Panning.Active:=False;
    Chart1.Draw;
  end;
end;