From Xojo Documentation

Revision as of 18:22, 23 July 2021 by Gperlman (talk | contribs)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from DesktopUIControl)

New in 2021r3

A Button is the standard button used in desktop apps. Examples are a Default button, a Cancel button or a standard button.

Closing FocusLost MouseExit
ConstructContextualMenu FocusReceived MouseMove
ContextualMenuItemSelected KeyDown MouseUp
DragEnter KeyUp MouseWheel
DragExit MouseDown Opening
DragOver MouseDrag Pressed
DropObject MouseEnter
Active fa-lock-32.png Height Parent
AllowAutoDeactivate Index fa-lock-32.png Scope fa-lock-32.png
AllowTabStop Italic TabIndex
Bold Left Tooltip
Cancel LockBottom Top
Caption LockLeft Transparent
Default LockRight Underline
Enabled LockTop Visible
FontName MacButtonStyle Width
FontSize MouseCursor Window fa-lock-32.png
FontUnit Name fa-lock-32.png
Handle fa-lock-32.png PanelIndex
AcceptFileDrop AddActionNotificationReceiver Refresh
AcceptPictureDrop Close RemoveActionNotificationReceiver
AcceptRawDataDrop DrawInto SetFocus
AcceptTextDrop Press


To set an accelerator character, precede the character in the Caption with an ampersand. In order to show an ampersand in the Caption, use two ampersands in a row. The sets the accelerator to the "D" character:

Calculate &Data

The DesktopButton's Caption property can show a caption that uses an encoding that doesn't match the application’s region code (or while running within the IDE, the IDE's region code). For example, an English application can set a Japanese caption, as long as it first sets the button's FontName to Osaka.

If your button has a height greater than 22 pixels, on macOS it will not have the standard rounded appearance and will instead be drawn as a square button. This is a restriction of macOS.

Linux and Pi Button Height

On Linux and Pi you may find that the button height is not large enough to fit the text. This is because some themes will drastically increase the default font size for buttons causing it to exceed the size of the button. There are a couple things you can do to fix this. In the Opening event of the Button you can choose to make the button larger:

Me.Height = 32

Or you can choose to make its font smaller:

Me.FontSize = 10

The above numbers are for example. You will want to adjust them as appropriate for the theme being used.

You can also look up the best size to use based on the theme by using Declares. Refer to this example project to see how it is done:


See Also

DesktopBevelButton, DesktopSegmentedButton controls; DesktopUIControl class.