As a Xojo web developer probably you’re used to embedding controls inside others, like
Containers; but I bet sometimes you don’t get the expected results. Read on to learn a quick fix that uses an extended method to correct a common problem you might run into when embedding menus.
In this example, think about a
WebPopupMenu embedded inside a rectangle that is embedded in a second rectangle. If the entries added to the WebPopupMenu are wider than the width of the rectangle it is embedded in or if it has more entries than the WebRectangle height, then these entries will be cropped in the deployed app. This screenshot better shows the problem:
The solution is quite easy! Just add an extended method to the
WebControl class (inside a
Module, where —Pro Tip!— you would likely want to add all these kinds of utility methods) and use the following signature when creating it:
- Method Name:
Extends Source As WebControl, Value As Boolean = true
Add the following snippet of code in the resulting Code Editor for the new method:
All we need to do now in the Shown Event of the PopupMenu is call our method on the instance:
Now we see the expected items all visible in the menu!
Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at Goto 10 and on Mastodon @firstname.lastname@example.org.