Skip to content

Web Control Improvements in Xojo 2014r2

There were several improvements to web controls in Xojo 2014 Release 2. Read on to learn more:

Add or Remove Toolbar Items

You can now add or remove Toolbar items at run-time. Previously, you could only design your Toolbar in the Layout Editor. You can use the AppendItem, InsertItem and RemoveItem methods of the WebToolbar class to modify the Toolbar at run-time.

This code adds a button to a toolbar called TestToolbar:

Dim button As New WebToolbarButton
button.Caption = "Button " + Str(TestToolbar.ItemCount + 1)
button.Enabled = True
TestToolbar.AppendItem(button)

This code inserts a button in the first position of a toolbar called TestToolbar:

Dim button As New WebToolbarButton
button.Caption = "Button"
button.Enabled = True<

TestToolbar.InsertItem(0, button)

This code removes the first item on a toolbar called TestToolbar:

TestToolbar.RemoveItem(0)

Add or Remove Segments

You can now add or remove segments of a Segmented Control at run-time. Previously, you could only design your Segmented Control in the Layout Editor. Modifying segments is done using the SegmentCount property of the WebSegmentedControl class.

This code adds another segment to SegmentedControl1 on a WebPage:

SegmentedControl1.SegmentCount = SegmentedControl1.SegmentCount + 1

SegmentedControl1.Segment(SegmentedControl1.SegmentCount - 1) = "Segment " + _
 Str(SegmentedControl1.SegmentCount)

This code removes the last segment:

SegmentedControl1.SegmentCount = SegmentedControl1.SegmentCount - 1

TextArea

TextArea has a new ScrollPosition property and a new SelectAll method. When there is a lot of text in a TextArea, you use the ScrollPosition property to set the topmost visible line. This scrolls the TextArea as necessary.

This code scrolls a TextArea to line 100:

TextArea1.ScrollPosition = 100

The SelectAll method is a quick and easy way to select all the text in the TextArea:

TextArea1.SelectAll

ListBox Selected Row Style

There is a new Style setting to specify the style for selected rows. Use the SelectionStyle property of the WebListBox class to assign a style for selected rows.

This code (in the Open event handler of a WebPage), applies an existing WebStyle (called MySelectionStyle) to use for selected rows in the ListBox:

SortableListBox.SelectionStyle = MySelectionStyle

Grab Xojo 2014 Release 2 today to try out these new features!