Lazarus

Programming => Widgetset => Other => Topic started by: vicot on May 23, 2013, 07:53:56 am

Title: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 07:53:56 am
Some time ago I read on this forum that there was work going on in the trunk about adding BiDi support to the native widgetset.
Is this BiDi-oriented effort still going on? What is its progress status?

Thanks

Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 11:04:37 am
What specifically do you need BiDi support for?  I may be able to help.  I have done a lot or work and have most things working for RightToLeft.
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 02:51:46 pm
Thanks, Avishai.
Simply to be able to edit text within a window, with mixed text (RTL & LTR) on the same line. For example, Arabic and English text on the same line.

Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 03:16:55 pm
If you mean something like "بامبسي sadff شسيبس sfasfd" then that should not be a problem.  You don't even need BiDiMode for that.  You can use TMemo for that.  You only need to switch Keyboard languages.  At least for MSWindows.  If you need something that can Left justify one line and Right justify the next, then I don't have an answer for that.

If you don't already have code for switching keyboard lang (MSWindows). let me know.

Edit: I typed the mixed text example in NotePad just switching lang.
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 03:26:19 pm
Yes, that's what I need to do.
So, you say that I don't even need Qt for that? That is, can I do it with LCL's native widgets?
Switching between keyboard layouts should not be a problem.

But one more question: when you have mixed text on the same line (as in the example you gave, which seems to be perfectly fine), and you move the cursor along the line (right and left arrow keys), how does the cursor behave, while moving from one end to the other of the line? Does it behave normally, i.e. as if it was normal text from the same language? Or by keeping pressed the same arrow key, the direction of the cursor suddenly changes when it reaches the text in the other language?

Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 03:37:00 pm
The cursor follows the direction of the lang. of the word it is on.  Try it in MSNotePad and you can see how it will behave in TMemo.  Punctuation is a bit problematic as well, but that's true in almost anything.  MSWord is about the only thing I know that will do it without using something like HTML where you insert specifiers to control word sections.
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 03:40:49 pm
Sorry, what do you mean by "follows the direction of the language"? In theory, when you press the right arrow key, the cursor should always move to the right, whatever the language. This is the proper (required) behaviour.
Sorry to be a bore, but you saying that when you press the right arrow key on Arabic text, it moves to left?
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 03:44:09 pm
Ok, I have just tried Notepad, as you suggested, and the cursor direction is inverted for Arabic, so that answers my question.

Do you know if this happens only on Windows, or is a feature of the class itself?
If so, where can I report this as a problem to be solved?

Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 03:44:32 pm
Yes.  If you are on an Arabic word, the Right Arrow moves to the Left.  It seems strange, but once you start using it you will see that it makes more sense this way.
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 03:47:56 pm
Sorry to contradict you, but it does NOT make sense. When the user hits an arrow key, he expects to see the cursor move in the direction visually indicated.

The best GUI toolkits (Qt and Gtk) overcome this problem, so that for example a right arrow key always moves the cursor right, even in Arabic.
Now the question is how to make modifications to TMemo.
Where can I report this feature request?
Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 03:56:00 pm
I see that we have different opinions on the "Best Normal" behavior, but that's OK.  As for feature request, you should use BugTracker (It's on the left side of this web page near the top).
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 04:16:22 pm
Should my feature request be filed in Bugtracker under the Lazarus or the FPC section?

(In theory, it concerns the class itself, so I am tempted to file it under FPC, but I just want to be sure.)

Thanks again
Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 04:23:57 pm
Under Lazarus.  TMemo is LCL so it's a Lazarus issue, not FPC.  But there are other answers besides TMemo.  You might want to try some of them first.  Maybe HTML is what you are looking for.
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 05:22:09 pm
Just to be clear: LCL cannot use Qt or Gtk2 as back-end, right? (If it could, my problem would be solved automatically).
Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 05:27:59 pm
OK.  I've tried MSWord, WordPad, NotePad, TMemo, Delphi's RichText, Visual Studio RichText and a couple of others and they all behave in the same way.  The cursor follows the direction of the word sequence they are in.  I think anything else would seem strange to me and I live in a mixed language world where I deal with R2L and L2R routinely.  I think what you are looking for is non-standard behavior for Windows.

I have no idea if you can use Qt or Gtk2 with Lazarus.
Title: Re: BiDi support in the native widgetset?
Post by: vicot on May 23, 2013, 05:35:04 pm
Yes, I know that most toolkits have this problem, including the native Windows GUI.
But the two best toolkits Qt and Gtk manage it right.
Thanks for your help, Avishai. I appreciate it.
Title: Re: BiDi support in the native widgetset?
Post by: Avishai on May 23, 2013, 06:26:12 pm
I disagree that it is "Right".  The meaning of the Left arrow key (in English) is to move to the previous letter of a word.  What you seem to want is that when it is in an Arabic word sequence, it should move to the Next letter.  I think most Middle Easterners would see that as very strange.

Also, when you activate BiDiMode, the Right/Left arrow keys reverse there meaning.  Left means Next and Right mean Previous.  You can test this in NotePad.  Type in some English text on one line and some Arabic text on another line.  Then press Ctrl/RightShift to activate Right To Left Reading Order.  Move to the end of what you typed in English and press the Left Arrow Key.  Then do the same in the Arabic text.
Title: Re: BiDi support in the native widgetset?
Post by: taazz on May 24, 2013, 02:03:04 am
since lcl uses the native controls of the OS the behavior you describe is not considered a bug you can report it if you like but you will get the same response from the team as well. In any case lcl can use both gtk and QT as the underline widgetset even on windows but you have to share those dlls with your application as well you shouldn't expect them to be installed by default. In any case open "project\Project Options" menu and select the "Build Modes" on the tree at the left on second grid at the right with the title "IDE macro Values" select the LCLWidgetType as the macro name and as a macro value you will be able to select gtk, qt or any other supported widgetset.

Make sure that you have GTK/QT installed on your system or your application will not run.
TinyPortal © 2005-2018