Class

WebToolbar


Description

Adds a toolbar to a WebPage.

Events

Name

Parameters

Returns

Closed

Hidden

MenuSelected

item As WebToolbarMenu, hitItem As WebMenuItem

Opening

Pressed

item As WebToolbarButton

Shown

TitlePressed

Enumerations

WebToolbar.Positions

Positions

The positions on the page where the toolbar can appear (top, bottom or default).

Enum

Description

Bottom

The toolbar will be displayed on the bottom of the webpage.

Inset

The toolbar will be displayed inset from the top on the webpage.

Top

The toolbar will be displayed on the top of the webpage.

Property descriptions


WebToolbar.ControlID

ControlID As String

Identifies the control on a per session basis.

This property is read-only.


WebToolbar.Enabled

Enabled As Boolean

When True the WebControl is drawn enabled and responds to user action. When False, the control appears as disabled and does not respond to user actions.

In the case of WebTimer, when set to False this disables and stops the WebTimer. When set to True, it starts the WebTimer.

Disable a button when a check box value changes:

If AllowSaveCheckBox.Value Then
  SaveButton.Enabled = True
Else
  AllowSaveButton.Enabled = False
End If

WebToolbar.FullWidth

FullWidth As Boolean

If True, the toolbar will consume the full with of the webpage.


WebToolbar.Icon

Icon As WebPicture


WebToolbar.Name

Name As String

The name of the control.

This property is read-only.


WebToolbar.Page

Page As WebPage

Identifies the web page that contains the control.

This property is read-only.


WebToolbar.Parent

Parent As WebControl

Used to get the control's parent control or page. If the parent control is a WebContainer, then it returns the WebContainer. If it is on a WebPage, it returns the WebPage.

This property is read-only.


WebToolbar.Position

Position As Positions

The position on the page where the toolbar will be displayed (bottom or top).


WebToolbar.Title

Title As String

The title of the toolbar.

Method descriptions


WebToolbar.AddItem

AddItem(item As WebToolbarItem)

Adds the item as a button to the toolbar.


WebToolbar.AddItemAt

AddItemAt(index As Integer, item As WebToolbarItem)

Adds the item to the toolbar at the index position.


WebToolbar.Close

Close

Removes the control from the page.


WebToolbar.ExecuteJavaScript

ExecuteJavaScript(script As String)

Executes the JavaScript passed. The JavaScript passed can call a JavaScript function in a WebPageSource control.

The Xojo web framework uses EcmaScript 6 which is more strict than previous versions of JavaScript. For more details, see the EcmaScript 6 documentation.

This code in the Pressed event of a Button displays an alert using JavaScript:

Me.ExecuteJavaScript("alert('Hello!');")

This code will select the text in a WebTextField (or WebTextArea):

WebTextField1.ExecuteJavascript("document.getElementById('" + _
  WebTextField1.ControlID + "_inner').select();")

WebToolbar.GotoURL

GotoURL(URL As String, inNewWindow As Boolean = False)

Opens the passed URL in place of the current web page or downloads a file. If InNewWindow is True, the browser is asked to open the URL in a new window.

If the browser has popup windows disabled and InNewWindow is True, the method silently fails and the page is not shown.

If InNewWindow is False, the running web app is replaced with the specified URL. If you want to display an external web site within your web app, use the WebHTMLViewer control.

Display a web site in a new popup window:

Me.GotoURL("http://www.wikipedia.org", True)

WebToolbar.ItemAt

ItemAt(index As Integer) As WebToolbarItem

Returns the WebToolbarItem as the index position.


WebToolbar.ItemWithTag

ItemWithTag(tag As Variant) As WebToolbarItem

Returns the WebToolbarItem whose tag matches the value passed.

If more than one WebToolbarItem has the same tag, the item with the lowest index and the matching tag is returned.

This method can be used when you don't want to rely upon the WebToolItem's index to retrieve it. For example, if you are going to be localizing the app into other languages, looping through the WebToolbarItems looking for a matching caption would be a poor choice. If you're going to be removing WebToolbarItems dynamically at runtime, using the index can be a poor choice because the higher indexes are renumbered when lower indexes are removed. You could remove them in order from highest to lowest to avoid this but it also doesn't make code that is very readable either. Using indexes also makes code that is difficult to maintain because adding new WebToolbarItems will change the indexes. This can all be avoided by assigning a unique value to the WebToolbarItem property each item you create one.


WebToolbar.LastItemIndex

LastItemIndex As Integer

The index of the last item in the WebToolbar.


WebToolbar.RemoveAllItems

RemoveAllItems

Removes all items from the WebToolbar.


WebToolbar.RemoveItemAt

RemoveItemAt(index As Integer)

Removes the WebToolbarItem at the index passed.


WebToolbar.UpdateBrowser

UpdateBrowser

Forces the current values of the control to be sent to the browser.

This method is useful when you are computing values in a loop and wish to update the browser immediately rather than wait until the current method ends.

This code iterates through a RowSet of database rows, updates a ProgressBar and then forces the updated ProgressBar to be sent to the browser via UpdateBrowser.

ProgressBar1.Maximum = SalesData.RowCount
For Each row As DatabaseRow in SalesData
 AnalyzeSales(row)
 ProgressBar1.Value = ProgressBar1.Value + 1
 ProgressBar1.UpdateBrowser
Next

Event descriptions


WebToolbar.Closed

Closed

The control has been removed from the browser either because the page has closed or the control's Close method was called.


WebToolbar.Hidden

Hidden

The control is about to become no longer visible. This could be because the page is being closed, is being replaced as the foreground page by another page or because the control or a parent control's Visible property has been set to False.

Note

This event is equivalent to the DesktopWindow.Deactivated event in a desktop app.


WebToolbar.MenuSelected

MenuSelected(item As WebToolbarMenu, hitItem As WebMenuItem)

The hitItem menu item was selected from the item button in the toolbar.


WebToolbar.Opening

Opening

The control has been created and the page is opening but has not been sent to the browser yet.

The Opening event handler can be used to initialize non-visual properties and settings for controls.

In most cases, you should use the Shown event to initialize controls.


WebToolbar.Pressed

Pressed(item As WebToolbarButton)

The item button in the toolbar was pressed.


WebToolbar.Shown

Shown

The control has appeared on the currently displayed page. This could be because its parent page just finished loading, its parent page has come to the foreground or the control is now visible having been previously invisible because it or its parent control's Visible property has been set to True.

Use the Shown event for initializing your controls or doing anything that would interact with other controls or user interface elements on the web page instead of the Opening event.

Note

This event is the web equivalent to the DesktopWindow.Activated event.


WebToolbar.TitlePressed

TitlePressed

The toolbar's title was pressed.

Notes

See the Pressed and MenuSelected events for example of how button clicks and menu selections are handled. See the Shown event handler for the code that populates the menu.

Sample code

This code adds a nested menu to a menu button:

// Create the menu
Var chartMenu As New WebMenuItem
Var lineMenu As New WebMenuItem("Lines")
lineMenu.AddMenuItem(New WebMenuItem("Dotted lines"))
lineMenu.AddMenuItem(New WebMenuItem("Solid lines"))
chartMenu.AddMenuItem(lineMenu)

// Assign it to the button
Var chartButton As WebToolbarButton
chartButton.DropDownMenu = chartMenu

Compatibility

Web projects on all supported operating systems.

See also

WebControl parent class; WebToolbarButton, WebToolbarItem, WebMenuItem, classes.