New Menu Implementation
Johan Segerfeldt posted in Developing in Bindows, Disruptive tech on March 3rd, 2009
Browsers have changed since the first menu implementations of Bindows were created. New restrictions caused various issues for our old menu implementations. For Bindows 4.0, I have been working on a brand new implementation written with these restrictions in mind. As a bonus, we now have nicer themes and we can expand the range of browsers we support. I hope you like what we’ve created.
Reasons for the change
In Bindows 3.0 (and previous versions) we had two different implementations for menus, XUL popups for Firefox and WebFX DHTML Menus 4 for Internet Explorer. These implementations allowed menus to be displayed anywhere on the screen. In Bindows 4.0 we have discarded these implementations and wrote a brand new one. Apart from unifying the two browsers, there are few additional reasons for this.
The ability to display a popup anywhere can be used maliciously (e.g. by hiding and impersonating an element of the main browser window). Since these implementations were first created, browser security patches have forbidden popups from being displayed outside the window (or even the frame) where they were created. As a result, Bindows menus that were placed near the bottom edge of the window/frame displayed some strange behavior. We were able to solve several of these issues, but some proved too difficult.
Additional browser support
Bindows 4.0 introduces support for WebKit based browsers (i.e. Safari and Google Chrome). Neither of the menu implementations would work for these browsers, so we would have to add a new implementation anyway. We might as well write one that would work for all browsers, and solve our menu issues at the same time.
As a result of the new implementation there has been one major API change. The left and top properties no longer relate to the screen, but to the parent component (which is usually the BiApplicationWindow).
Two new methods have been added: popupAtComponent(oComponent) and popupAtMouse(oMouseEvent). The first sets the component property and displays the menu just below oComponent. The latter uses the mouse coordinates (from oMouseEvent) to display the menu.
The fact that we have a single implementation for all supported browsers means we also have only one set of CSS styles (for each theme), which applies to all users. When we created our brand new themes for Bindows 4.0, we took this opportunity to revamp the theme properties for menus, making the CSS classes consistent with the rest of Bindows. Your old themes will not be compatible with Bindows 4.0 without some changes. The good news is that we have many compatible themes, free to download at http://www.bindows.net/download/themes/.