AvalonEdit icon indicating copy to clipboard operation
AvalonEdit copied to clipboard

Alt-Keypress not marked as handled when rectangular selection is done

Open DanielRose opened this issue 10 years ago • 2 comments

In my application, I use AvalonEdit as text editor, whilst also having a third-party Ribbon control. That Ribbon control shows keyboard shortcuts when the user presses the Alt-Key. In general this works.

However, when doing a rectangular selection using the mouse (i.e. press Alt, drag with mouse, release Alt), the Alt-KeyUp event is not marked as handled by AvalonEdit. This results in the Ribbon incorrectly showing the keyboard shortcuts (since it seems that user simply pressed and released the Alt-Key).

DanielRose avatar Jul 30 '15 14:07 DanielRose

I was able to make a workaround, via handlers for PreviewMouseLeftButtonDown and KeyUp (essentially trying to check if a rectangular selection had occurred). A better solution would be to fix this in the code (I can send a PR), but I don't know if you want such a change.

DanielRose avatar Jul 30 '15 14:07 DanielRose

When creating a rectangular selection you first press [Alt] and then use the mouse or the keyboard to select text. When [Alt] is first pressed, we can't and shouldn't mark the key press as handled by AvalonEdit because it might be intentional to show the accessor keys. On the other hand it is impossible to go back in time and change our decision once selection via mouse or keyboard starts.

If you have a pull request/solution for this, you are welcome to provide it. However I don't see how we could fix this because we would end up eating all Alt key-presses.

Other editors like Notepad++ behave the same. The accessor keys in menu bars are simply less visible and therefore you never notice them while editing text.

siegfriedpammer avatar Feb 23 '20 08:02 siegfriedpammer