Fix inverted RTL word navigation in the subtitle edit box#11715
Conversation
7581526 to
a6ce028
Compare
|
This caught my eye because there was a recent fix made to let Ctrl+Right/LeftArrow skip words instead of navigating the video. This was an issue of there being shortcuts for video navigation that happen to collide with Windows standard keyboard combinations that navigate text. The solution was to suspend recognition of the shortcuts while focus is in the text box. At least, that's my understanding of the solution. I'm just a user. I have no hope of ever actually understanding the code were I to see it. However, I take issue with your selection of Ctrl+Up/DownArrow as text movement keyboard directives. These are NOT standard text editing operations in Windows. To go to the beginning of a line, the standard keyboard operation is the Home key. For line end, it's the End key. To go to the beginning of the text in the textbox -- like if there's 2 lines of text & the cursor is somewhere in the second line -- the standard key combination is Ctrl+Home. To go to the end of the text, it's Ctrl+End. So I say that you should remove whatever logic you have coded to recognize Ctrl+Up/DownArrow. The keystrokes I have described are provided by Windows itself & these should simply be allowed to operate within the textbox. This should not be an issue of left-to-right vs right-to-left text orientation. To my way of thinking, making sure Ctrl+Left/RightArrow swap directions depending on RTL or LTR seems valid. But the rest does not seem valid. In addition, I would assume there are keyboard operations on Mac that are equivalent to the ones I've described for Windows. You should not add code that duplicates what the operating system already provides. If standard keystrokes don't filter through in the textbox on Mac, you should be looking at suspending colliding shortcuts from interfering with standard text operations defined in the operating system, not customizing new keystrokes to circumvent the root cause. |
|
Thank you for your comment, In SE4, on Windows, ctrl + up or down arrows would take you to the head or end of the line you are in if your are using the text box, double do that and it would take you to the head of the first line if you were in the second in case you had two. However, this was not functioning properly in latest 5 release, and in Arabic language it is even inverted, that is what I was trying to fix actually. |
01b3ba8 to
4583ce8
Compare
|
Still working on this, and will confirm once I test it myself. |
83a7320 to
960cc51
Compare
|
Tested and working on macOS 26.5 (Apple Silicon) from a local build of this branch, with Arabic subtitles, in both edit-box modes (the AvaloniaEdit editor used when color tags are on, and the plain TextBox). Behaviour (right-to-left text only)For a focused subtitle edit box whose content is right-to-left, caret navigation now moves in the visually-correct direction, using each platform's standard navigation keys:
Why it lives in the key pipelineA handler attached directly to the Two implementation notes:
Scope — what is NOT affected
Verified on-device: word nav (Option and the Cmd-position key), line nav, Shift-extend accumulation across multiple words and to line edges, bare-arrow collapse to the correct edge, and LTR/English left unaffected. |
|
Is there any changes or enhancements that you suggest me to edit or improve? |
In a right-to-left subtitle, word and line caret navigation jumped the wrong way. Avalonia (and AvaloniaEdit, used when color tags are on) move whole words by logical text offset, which runs backwards for RTL text; single-character steps were already visually correct. Handle these keys in the central OnKeyDownHandler - the same place the edit box already overrides keys (e.g. the Return-key line limiter) by marking the event handled in the root tunnel phase, which reliably pre-empts the editor's built-in navigation. A side TextBox/TextArea handler does not win against AvaloniaEdit, which is why this lives in the key pipeline instead. For right-to-left text in the focused edit box (detected by content, per line with a whole-box fallback - a subtitle is usually edited in an otherwise LtR window so FlowDirection stays LtR), using the platform's standard navigation keys: - Word: Ctrl+Left/Right everywhere; Option(Alt)+Left/Right on macOS - moves a word in the visually-correct direction. - Line: Command(Meta)+Left/Right on macOS - moves to the visual start/end of the line. - Shift extends the selection. Movement goes through the ITextBoxWrapper abstraction, so it works for both the plain TextBox and the AvaloniaEdit TextEditor edit-box implementations. Left-to-right text keeps native navigation, and non-arrow shortcuts (copy / paste / undo) plus Home / End are untouched.
960cc51 to
a85495e
Compare
What
Fixes Ctrl+Left / Ctrl+Right jumping the wrong way when editing a right-to-left subtitle (e.g. Arabic), and makes Ctrl+Up / Ctrl+Down go to the start / end of the current line.
Why
Avalonia's
TextBoxmoves the caret one character visually (bidi-aware, already correct) but moves whole words by logical text offset, so word steps run opposite to the visual direction under RTL. Single-character steps were fine; word steps were inverted.How
A tunnel-phase key handler on the main and original edit text boxes that runs only when the box is in RTL flow:
It no-ops for left-to-right editing, so LTR behaviour and global Ctrl+Arrow shortcuts are unchanged.
Note: please verify in a real RTL editing session - developed on macOS, not yet runtime-tested.