Bug #4570


RTL support for WNavigationBar (and WMenu)

Added by Samir Shaker over 8 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:



WNavigationBar and the WMenu inside it do not behave correctly when setLayoutDirection(RightToLeft) is called. I have tried to implement a fix for it, but I am not familiar enough with the architecture of Wt yet, so I wasn't completely successful. I am not sure in which function the code should be added. I have attached three screenshots to help clarify the problem. WNavigationBar_noRTL.png shows the navigation bar without RTL, WNavigationBar_wrongRTL.png shows how the current buggy implementation behaves, and WNavigationBar_correctRTL.png is a screenshot that I have edited approximating how it should look for correct RTL behavior. I have also included a main.cpp file, which was used to take the screenshots and should help illustrate the problem better and implement a fix. It's a modification of the example found here

While trying to implement the fix myself, here is what I have learned:

1- RTL for WMenu should be implemented first, since it's part of a typical WNavigationBar setup. This can be done by calling item->setAttributeValue("style", "float: right") on every WMenuItem inside WMenu whenever RTL is enabled.

2- Every menu added to the navigation bar should have the opposite alignment specified. For example, a call to navigation->addMenu(rightMenu, Wt::AlignRight) should actually align the menu to the left instead of to the right, and a default call to the function without a second argument should align the menu to the right.

3- The navigation bar title should go all the way to the right instead of to the left. I am not sure how to achieve this yet, as I wasn't able to successfully implement step 2, so I didn't get this far. But it is probably the simplest thing of the three to implement.

I am willing to implement this fix with some guidance, or maybe it is easy enough for you guys to implement a fix without much trouble. In any case, I would appreciate any feedback on this issue.

Thank you,



WNavigationBar_noRTL.png (39.1 KB) WNavigationBar_noRTL.png Without RTL Samir Shaker, 11/16/2015 06:44 AM
WNavigationBar_wrongRTL.png (44 KB) WNavigationBar_wrongRTL.png The current (wrong/inexistent) RTL behavior Samir Shaker, 11/16/2015 06:44 AM
WNavigationBar_correctRTL.png (29.6 KB) WNavigationBar_correctRTL.png An illustration of correct RTL behavior Samir Shaker, 11/16/2015 06:44 AM
main.cpp (1.94 KB) main.cpp Sample test code Samir Shaker, 11/16/2015 06:44 AM

No data to display


Also available in: Atom PDF