Submenu hides parentmenu when placed near the right border [message #1740883] |
Fri, 19 August 2016 10:54 |
Magnus Konze Messages: 13 Registered: November 2014 |
Junior Member |
|
|
Hi,
i have a menu in the top right corner of my application. If this menu has submenus, those items are shown over their parentmenu.
As long as all labels are shorter than the lables in the parentmenu, this is not a problem. But if there is one long label, the parentmenu will be completly hidden by the submenu and you can't get back to the parentmenu.
In SWT submenus pop up on the left of their parentmenu, if there is not enough space.
Is there any property to enable the SWT-bahaviour?
If not, is there a way to reposition the submenu? I tried different Listeners (Show, Selection), but Menu.setLocation(...) didn't seem to work.
Regards
Magnus
-
Attachment: menu.png
(Size: 2.25KB, Downloaded 331 times) -
Attachment: submenu.png
(Size: 2.34KB, Downloaded 322 times)
[Updated on: Fri, 19 August 2016 10:56] Report message to a moderator
|
|
|
Re: Submenu hides parentmenu when placed near the right border [message #1742550 is a reply to message #1740883] |
Sun, 04 September 2016 23:55 |
Chris Fairhall Messages: 221 Registered: February 2011 |
Senior Member |
|
|
I raised this as https://bugs.eclipse.org/bugs/show_bug.cgi?id=372176
I use these patches and build my own version
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js
index 7af0862..35e7b45 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js
@@ -286,6 +286,16 @@ rwt.qx.Class.define("rwt.widgets.base.Popup",
left = docWidth - restrictToPageRight - width;
}
+ if( this._opener instanceof rwt.widgets.MenuItem ) {
+ var parentMenu = this._opener.getParentMenu();
+ var parentLeft = parentMenu.getLeft();
+ if (parentLeft) {
+ if (left < parentLeft) {
+ left = parentLeft - width;
+ }
+ }
+ }
+
if (top + height > docHeight - restrictToPageBottom) {
top = docHeight - restrictToPageBottom - height;
}
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js
index 35e7b45..b1df5dd 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/Popup.js
@@ -288,9 +288,10 @@ rwt.qx.Class.define("rwt.widgets.base.Popup",
if( this._opener instanceof rwt.widgets.MenuItem ) {
var parentMenu = this._opener.getParentMenu();
- var parentLeft = parentMenu.getLeft();
- if (parentLeft) {
- if (left < parentLeft) {
+ var parentLeft = parentMenu.getLeftValue();
+ var parentWidth = parentMenu.getWidthValue();
+ if (parentLeft && parentWidth) {
+ if (left < (parentLeft + parentWidth - 5)) {
left = parentLeft - width;
}
}
As they are, I don't think they're good enough to be contributed. I'm not sure how it will handle very narrow windows or very wide menus
I think with just the first patch, the sub-menu will only be moved from its usual position if it fully covers the parent menu. With the second patch, this behaviour is changed so the sub-menu is moved to the left if it would cover any of the parent menu - which is how SWT on windows behaves.
I don't think my fix is in the correct place in the code, there are no tests covering it and the hard-coded '5' isn't going to work with theme support.
|
|
|
Powered by
FUDForum. Page generated in 0.02876 seconds