Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 1963

Arabic in TEdit->Text and apparent cursor location

$
0
0

I hope someone here is familiar with Arabic. My problem is that when working in a TEdit that is showing Arabic, the cursor does not appear in the correct position.  Here's an example. Edit1 is a TEdit that has been created elsewhere in the program.

    Edit1->Visible = true;
    Edit1->SetFocus();
    String letterArabic = L"\u0631\u0633\u0627\u0644\u0629";
    Edit1->Text = letterArabic;
    Edit1->SelStart = 0;

The program runs fine, and it correctly displays the Arabic word, 'risala', which happens to be the word for "letter," or "missive." Unfortunately, the cursor is then shown flashing between the rightmost and next to rightmost characters. (Between the "first" and "second" characters from an Arabic point of view, reading from right to left.) I want it to appear at the far left, the end of the Arabic word, where another letter might be added by a user. I tried replacing the last line with

    Edit1->SelStart = letterArabic.Length();

but that made the cursor show up far to the right of the Arabic text.

I think it's pretty clear that the operating system is tracking positions in the window, and interpreting SelStart in terms of those positions, even though the Arabic letters aren't fitting into those slots, so to speak.

Note, that the problem only concerns where the cursor APPEARS to be. With the above code, if the user simply strikes a letter key, say 'x', the 'x' shows up at the far left, to the left of all the Arabic characters; the 'x' does NOT up where the cursor was flashing! In other words, the SelStart = 0 is working. Further, if I then fetch the Text with

String temporary = Edit1->Text;

the user's 'x' will be at temporary[1].

Incidentally, two technical notes. 1) The above Unicode designations for the Arabic letters are from the 06 page, not the FE page, The difference is that, if a character is given its 06 page designation, then a lot of software correctly adjusts the letter's appearance in light of its context, i.e., the form of the letter changes, sometimes radically, in order to link correctly to its following and preceding letters. The sequence of the same characters, using the FE page numbers, will be displayed by most software without that adjustment. Adjustment is happening correctly here. 2) The program is also correctly writing from right to left, i.e., letterArabic[1] appears at the far right, followed by letterArabic[2] to its left, etc.

I should also mention that I have seen this and similar problems with other software. I think I have seen it with MS Word. Open Office generally handles the issues better, but period (.) and (,) do not appear where the cursor is flashing, when one is doing word processing with Open Office and the Windows Arabic keyboard. Thanks in advance for any insights. I want to make my product user friendly, so I want the user to see correctly where, within the sequence, his or her next key stroke will appear.

River_Forest


Viewing all articles
Browse latest Browse all 1963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>