Class

MobileCanvas


Description

Used to draw graphics.

Events

Name

Parameters

Returns

AppearanceChanged

dark As Boolean

Closing

KeyDown

Key As String

Boolean

Opening

Paint

g As Graphics

PointerDown

position As Point, pointerInfo() As PointerEvent

PointerDrag

position As Point, pointerInfo() As PointerEvent

PointerUp

position As Point, pointerInfo() As PointerEvent

TextReceived

text As String

Property descriptions


MobileCanvas.AccessibilityHint

AccessibilityHint As String

The accessibility hint is a longer description that is read aloud when VoiceOver is enabled.

Me.AccessibilityHint = "Click to calculate the value and display the next screen."

MobileCanvas.AccessibilityLabel

AccessibilityLabel As String

The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.

Me.AccessibilityLabel = "Calculate the value."

MobileCanvas.AllowKeyEvents

AllowKeyEvents As Boolean

If True and the MobileCanvas is both enabled and has the focus, key events will be received.

If no hardware keyboard is attached, the onscreen keyboard will appear when the MobileCanvas has the focus.

Important

This property is not currently supported for Android.


MobileCanvas.ControlCount

ControlCount As Integer

The number of child controls in the control.

This property is read-only.

Important

This property is supported for iOS only.


MobileCanvas.Enabled

Enabled As Boolean

Indicates whether the control is enabled or disabled.

Disable the button:

Button1.Enabled = False

MobileCanvas.Height

Height As Integer

The height of the control.

This property is read-only on iOS.


MobileCanvas.Left

Left As Integer

The left position of the control.

This property is read-only on iOS.


MobileCanvas.LockBottom

LockBottom As Boolean

Determines whether the bottom edge of the control should stay at a set distance from the bottom edge of the parent control, if there is one, or the owning screen.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockBottom = True

MobileCanvas.LockLeft

LockLeft As Boolean

Determines whether the left edge of the control should stay at a set distance from the left edge of the parent control, if there is one, or the owning screen.

LockLeft and Locktop default to True when you add a new control to a screen. Existing controls will be altered only if LockRight and/or LockBottom are not set. LockLeft has no effect unless LockRight is True.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockLeft = True

MobileCanvas.LockRight

LockRight As Boolean

Determines whether the right edge of the control should stay at a set distance from the right edge of the parent control, if there is one, or the owning screen.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockRight = True

MobileCanvas.LockTop

LockTop As Boolean

Determines whether the top edge of the control should stay at a set distance from the top edge of the parent control, if there is one, or the owning screen.

LockTop and LockLeft default to True when you add a control to a screen. Existing controls will be altered only if LockRight and/or LockBottom are not set. LockTop has no effect unless LockBottom is True.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockTop = True

MobileCanvas.Name

Name As String

The name of the control.


MobileCanvas.Parent

Parent As MobileUIControl

The parent (sometimes called a "Super") class of the control.

This property is read-only.


MobileCanvas.TintColor

TintColor As ColorGroup

Changes a control's tint color.

Important

This property is not currently supported for Android.

On iOS, the following controls support TintColor:

Enum

Description

ProgressBar

The area indicating the value of the control will be drawn in the TintColor.

Slider

The area indicating the value of the control will be drawn in the TintColor.

TextArea

The cursor and text highlight color will be drawn in the TintColor.

TextField

The cursor and text highlight color will be drawn in the TintColor.


MobileCanvas.Top

Top As Integer

The top position of the control.

This property is read-only on iOS.


MobileCanvas.Visible

Visible As Boolean

Indicates whether the control is visible.

Make a button invisible:

Button1.Visible = False

MobileCanvas.Width

Width As Integer

The width of the control.

This property is read-only on iOS.

Method descriptions


MobileCanvas.AddConstraint

AddConstraint(constraint As iOSLayoutConstraint)

Adds a constraint to the control.

This constraint is used by child controls that have been added to this control.

Important

This is supported for iOS only.


MobileCanvas.AddControl

AddControl(child As MobileUIControl)

Adds a child control to the control.

Important

This is supported for iOS only.


MobileCanvas.ClearFocus

ClearFocus

Removes the focus from the control.

TextField1.ClearFocus

MobileCanvas.ControlAt

ControlAt(index As Integer) As MobileUIControl

Gets the child control at the specified index.

Important

This is supported for iOS only.


MobileCanvas.Controls

Controls As Iterable

Allows you to iterate through all the controls that have been added to this control.

Important

This is supported for iOS only.


MobileCanvas.Handle

Handle As Ptr

The handle to the underlying native OS control.


MobileCanvas.Refresh

Refresh

Marks the control so that it will be redrawn during the next event loop.

Call Refresh to force a Canvas to redraw itself:

Canvas1.Refresh

MobileCanvas.RemoveConstraint

RemoveConstraint(constraint As iOSLayoutConstraint)

Removes a constraint from the control.

Important

This is supported for iOS only.


MobileCanvas.RemoveControl

RemoveControl(child As MobileUIControl)

Removes the control from the control.

Important

This is supported for iOS only.


MobileCanvas.SetFocus

SetFocus

Sets the focus to the control.

TextField1.SetFocus

Event descriptions


MobileCanvas.AppearanceChanged

AppearanceChanged(dark As Boolean)

Called when the device switches between Light and Dark mode.

Use this event to update any graphics or other UI as needed.

Important

This event is not supported for Android.


MobileCanvas.Closing

Closing

Called when the control's layout is closing.


MobileCanvas.KeyDown

KeyDown(Key As String) As Boolean

The user has pressed the Key passed while the MobileCanvas has the focus.

Returning True prevents the KeyDown event on the parent control (usually the screen) from executing. Returning False results in the execution of the KeyDown event of the parent control.

To receive key events, AllowKeyEvents must be True, the MobileCanvas must be enabled and have the focus.

Important

This event is not supported for Android.


MobileCanvas.Opening

Opening

Called when the control's layout is opening.

This is where you typically put initialization code.

This example in the Opening event of a label sets its text to "Hello":

Me.Text = "Hello"

MobileCanvas.Paint

Paint(g As Graphics)

Called when the Canvas needs to be redrawn.

To draw a blue rectangle in the Canvas:

g.DrawingColor = Color.Blue
g.FillRectangle(0, 0, g.Width, g.Height)

MobileCanvas.PointerDown

PointerDown(position As Point, pointerInfo() As PointerEvent)

Called when the pointing device (finger or pen) touches the Canvas.

This code saves all touch points to an array, which is used to display circles in the Paint event:

' touchPoints is an PointerEvent array property of screen the Canvas is also on
touchPoints = pointerInfo
Me.Refresh

This code goes in the Paint event handler:

For Each tap As PointerEvent In touchPoints
  g.DrawingColor = Color.Blue
  g.FillOval(tap.Position.X, tap.Position.Y, 30, 30)
Next

MobileCanvas.PointerDrag

PointerDrag(position As Point, pointerInfo() As PointerEvent)

Called when the pointing device (finger or pen) is dragged.


MobileCanvas.PointerUp

PointerUp(position As Point, pointerInfo() As PointerEvent)

Called when the pointing device (finger or pen) is raised or released.


MobileCanvas.TextReceived

TextReceived(text As String)

Text has been entered the length of which is more that just a keystroke. For example, this occurs when pasting text from the Clipboard or when using the dictation feature from the iOS Keyboard.

Important

This event is not currently supported for Android.

Compatibility

Mobile projects on all supported mobile operating systems.

See also

MobileUIControl parent class; PointerEvent, Graphics classes