1. Toybox.WatchUi
   URL: https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html
   Toybox.WatchUi

# Module: Toybox.WatchUi

## Overview

The WatchUi module contains user interface elements available within apps.

WatchUi provides several classes that represent Views, or what is displayed on the screen of a device. Also available are UI elements like on-screen menus, progress bars, buttons, and various pickers. More abstract classes represent all drawable objects, such as bitmaps and text.

Note:

All keys in the key types enum listed after EXTENDED_KEYS (16) were added after ConnectIQ version 1.1.2. Before evaluating these keys, check for the availability of these keys with a`has` check: if (Toybox.WatchUi has :EXTENDED_KEYS)...

## Classes Under Namespace

## Constant Summary

### Key

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| KEY_POWER | 0 | API Level 1.0.0 | The power key |
| KEY_LIGHT | 1 | API Level 1.0.0 | The light key |
| KEY_ZIN | 2 | API Level 1.0.0 | The zoom in key |
| KEY_ZOUT | 3 | API Level 1.0.0 | The zoom out key |
| KEY_ENTER | 4 | API Level 1.0.0 | The enter key |
| KEY_ESC | 5 | API Level 1.0.0 | The escape key |
| KEY_FIND | 6 | API Level 1.0.0 | The find key |
| KEY_MENU | 7 | API Level 1.0.0 | The menu key |
| KEY_DOWN | 8 | API Level 1.0.0 | The down key |
| KEY_DOWN_LEFT | 9 | API Level 1.0.0 | The down left key |
| KEY_DOWN_RIGHT | 10 | API Level 1.0.0 | The down key |
| KEY_LEFT | 11 | API Level 1.0.0 | The left key |
| KEY_RIGHT | 12 | API Level 1.0.0 | The right key |
| KEY_UP | 13 | API Level 1.0.0 | The up key |
| KEY_UP_LEFT | 14 | API Level 1.0.0 | The up-left |
| KEY_UP_RIGHT | 15 | API Level 1.0.0 | The up-right key |
| EXTENDED_KEYS | 16 | API Level 1.1.2 | Indicates extended key support |
| KEY_PAGE | 17 | API Level 1.1.2 | The page key |
| KEY_START | 18 | API Level 1.1.2 | The start key |
| KEY_LAP | 19 | API Level 1.1.2 | The lap key |
| KEY_RESET | 20 | API Level 1.1.2 | The reset key |
| KEY_SPORT | 21 | API Level 1.1.2 | The sport key |
| KEY_CLOCK | 22 | API Level 1.1.2 | The clock key |
| KEY_MODE | 23 | API Level 1.1.2 | The mode key |
| KEY_ACTION_MENU | 24 | API Level 5.1.1 | The action menu key |

### AnimationType

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ANIM_TYPE_LINEAR | 0 | API Level 1.0.0 | Animation with a constant speed |
| ANIM_TYPE_EASE_IN | 1 | API Level 1.0.0 | Animation that increases in speed from start to end |
| ANIM_TYPE_EASE_OUT | 2 | API Level 1.0.0 | Animation that decreases in speed from start to end |
| ANIM_TYPE_EASE_IN_OUT | 3 | API Level 1.0.0 | Animation that increases in speed from the start, then decreases in speed toward the end |

### KeyPressType

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| PRESS_TYPE_DOWN | 0 | API Level 1.1.2 | The key is pressed down |
| PRESS_TYPE_UP | 1 | API Level 1.1.2 | The key is released |
| PRESS_TYPE_ACTION | 2 | API Level 1.1.2 | The key's action is performed |

### ClickType

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CLICK_TYPE_TAP | 0 | API Level 1.0.0 | A tap on the screen |
| CLICK_TYPE_HOLD | 1 | API Level 1.0.0 | A press and hold on the screen |
| CLICK_TYPE_RELEASE | 2 | API Level 1.0.0 | A release of a hold on the screen |

### MapMarkerIcon

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| MAP_MARKER_ICON_PIN | 0 | API Level 3.0.0 | The default Garmin map marker pin icon |

### MapMode

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| MAP_MODE_PREVIEW | 0 | API Level 3.0.0 | The preview mode for a MapView |
| MAP_MODE_BROWSE | 1 | API Level 3.0.0 | The browse mode for a MapView |

### SwipeDirection

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| SWIPE_UP | 0 | API Level 1.0.0 | A swipe in the upward direction |
| SWIPE_RIGHT | 1 | API Level 1.0.0 | A swipe towards the right |
| SWIPE_DOWN | 2 | API Level 1.0.0 | A swipe in the downward direction |
| SWIPE_LEFT | 3 | API Level 1.0.0 | A swipe towards the left |

### DragType

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| DRAG_TYPE_START | 0 | API Level 3.3.0 | Start of a screen drag |
| DRAG_TYPE_CONTINUE | 1 | API Level 3.3.0 | Continuation of a screen drag |
| DRAG_TYPE_STOP | 2 | API Level 3.3.0 | Stop of a screen drag |

### ControlBarLeftButton

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CONTROL_BAR_LEFT_BUTTON_BACK | 0 | API Level 4.1.2 | |
| CONTROL_BAR_LEFT_BUTTON_CANCEL | 1 | API Level 4.1.2 | |

### ControlBarRightButton

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CONTROL_BAR_RIGHT_BUTTON_ACCEPT | 2 | API Level 4.1.2 | |
| CONTROL_BAR_RIGHT_BUTTON_MENU | 3 | API Level 4.1.2 | |

### AnalogClockState

Set the state for analog clock hands

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ANALOG_CLOCK_STATE_RESTING | 0 | API Level 3.3.0 | Set the clock hands to resting position |
| ANALOG_CLOCK_STATE_SYSTEM_TIME | 1 | API Level 3.3.0 | Set the clock hands to system time |
| ANALOG_CLOCK_STATE_HOLDING | 2 | API Level 3.3.0 | Set the clock hands to the specified position |

### WatchFaceConfigType

WatchFace config types.

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| WATCH_FACE_CONFIG_TYPE_STYLE | 0 | API Level 5.1.0 | |
| WATCH_FACE_CONFIG_TYPE_COMPLICATION | 1 | API Level 5.1.0 | |
| WATCH_FACE_CONFIG_TYPE_ACCENT_COLOR | 2 | API Level 5.1.0 | |
| WATCH_FACE_CONFIG_TYPE_COMPLICATION_COLOR | 3 | API Level 5.1.0 | |

### MenuTheme

Menu theme for supported devices

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| MENU_THEME_DEFAULT | 0 | API Level 4.1.8 | The default theme color as specified by the device. |
| MENU_THEME_BLUE | 1 | API Level 4.1.8 | |
| MENU_THEME_CYAN | 2 | API Level 4.1.8 | |
| MENU_THEME_GREEN | 3 | API Level 4.1.8 | |
| MENU_THEME_YELLOW | 4 | API Level 4.1.8 | |
| MENU_THEME_ORANGE | 5 | API Level 4.1.8 | |
| MENU_THEME_RED | 6 | API Level 4.1.8 | |
| MENU_THEME_PINK | 7 | API Level 4.1.8 | |
| MENU_THEME_PURPLE | 8 | API Level 4.1.8 | |
| MENU_THEME_GREEN_YELLOW | 9 | API Level 4.1.8 | |

### Confirm

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CONFIRM_NO | 0 | API Level 1.0.0 | |
| CONFIRM_YES | 1 | API Level 1.0.0 | |

### NumberPickerMode

This has been deprecated

This enum may be removed after System 3.

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| NUMBER_PICKER_DISTANCE | 0 | API Level 1.0.0 | A Float in meters (m) |
| NUMBER_PICKER_TIME | 1 | API Level 1.0.0 | A Duration |
| NUMBER_PICKER_TIME_MIN_SEC | 2 | API Level 1.0.0 | A Duration |
| NUMBER_PICKER_TIME_OF_DAY | 3 | API Level 1.0.0 | A Duration representing the number of seconds since midnight |
| NUMBER_PICKER_WEIGHT | 4 | API Level 1.0.0 | A Float in kilograms (kg) |
| NUMBER_PICKER_HEIGHT | 5 | API Level 1.0.0 | A Float in meters (m) |
| NUMBER_PICKER_CALORIES | 6 | API Level 1.0.0 | A Number |
| NUMBER_PICKER_BIRTH_YEAR | 7 | API Level 1.0.0 | A Number |

### SlideType

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| SLIDE_IMMEDIATE | 0 | API Level 1.0.0 | No transition. |
| SLIDE_LEFT | 1 | API Level 1.0.0 | The View slides to the left. |
| SLIDE_RIGHT | 2 | API Level 1.0.0 | The View slides to the right. |
| SLIDE_DOWN | 3 | API Level 1.0.0 | The View slides down. |
| SLIDE_UP | 4 | API Level 1.0.0 | The View slides up. |
| SLIDE_BLINK | 5 | API Level 3.1.0 | The View fades in. |

### LayoutVerticalAlignment

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| LAYOUT_VALIGN_TOP | -0x7FFFFFFF | API Level 1.2.0 | Set a Drawable object's locY property to this to align it to the top edge of the device context (Dc). |
| LAYOUT_VALIGN_BOTTOM | -0x7FFFFFFE | API Level 1.2.0 | Set a Drawable object's locY property to this to align it to the bottom edge of the device context (Dc). |
| LAYOUT_VALIGN_CENTER | -0x7FFFFFFD | API Level 1.2.0 | Set a Drawable object's locY property to this to center it vertically in the device context (Dc). |
| LAYOUT_VALIGN_START | -0x7FFFFFFC | API Level 1.2.0 | Set a Drawable object's locY property to this to make it equal to its parent's locY property. |

### LayoutHorizontalAlignment

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| LAYOUT_HALIGN_LEFT | -0x7FFFFFFF | API Level 1.2.0 | Set a Drawable object's locX property to this to align it along the left edge of the device context (Dc). |
| LAYOUT_HALIGN_RIGHT | -0x7FFFFFFE | API Level 1.2.0 | Set a Drawable object's locX property to this to align it along the right edge of the device context (Dc). |
| LAYOUT_HALIGN_CENTER | -0x7FFFFFFD | API Level 1.2.0 | Set a Drawable object's locX property to this to center it horizontally in the device context (Dc). |
| LAYOUT_HALIGN_START | -0x7FFFFFFC | API Level 1.2.0 | Set a Drawable object's locX property to this to make it equal to its parent's locX property. |

### AnimationEvent

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ANIMATION_EVENT_COMPLETE | 0 | API Level 3.1.0 | Indicates the completion of an animation. |
| ANIMATION_EVENT_CANCELED | 1 | API Level 3.1.0 | Indicates the cancel of the animation playback |

### ActionMenuTheme

The theme for the ActionMenu

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ACTION_MENU_THEME_DARK | 0 | API Level 3.4.0 | Dark theme for the action menu |
| ACTION_MENU_THEME_LIGHT | 1 | API Level 3.4.0 | Light theme for the action menu |

### ReviewRequestStatus

Enum class for makeReviewTokenRequest return status

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| REVIEW_REQUEST_STATUS_GRANTED | 0 | API Level 3.4.2 | |
| REVIEW_REQUEST_STATUS_DENIED | 1 | API Level 3.4.2 | |
| REVIEW_REQUEST_STATUS_FAILED | 2 | API Level 3.4.2 | |

## Typedef Summary collapse

## Instance Method Summary collapse

animate(object as Lang.Object, property as Lang.Symbol, type as WatchUi.AnimationType, start as Lang.Numeric, stop as Lang.Numeric, period as Lang.Numeric, callback as Null or Lang.Method() as Void) as Void

Animate an Object.

cancelAllAnimations() as Void

Cancel animations started with WatchUi.animate() Stop all animations that were started with WatchUi.animate().

configureTouchEvents(options as WatchUi.TouchEventSettings) as Lang.Boolean

Configurate touch event settings, only allowed for Watch Apps and Audio Content Providers when running in the foreground mode.

getCurrentView() as [WatchUi.View or Null, WatchUi.InputDelegates or Null ]

Get the current view that is displayed in the UI.

getSubscreen() as Graphics.BoundingBox or Null

Get the subscreen area in the display.

getTouchEventsConfiguration() as WatchUi.TouchEventSettings

Returns the current touch event settings.

loadResource(resource as Lang.ResourceId) as WatchUi.Resource

Load a resource from the executable.

makeReviewTokenRequest(callback as Lang.Method(responseStatus as WatchUi.ReviewRequestStatus, token as WatchUi.ReviewResponseToken or Null) as Void) as Void

Initiate a request to ask for this app to be reviewed.

popView(transition as WatchUi.SlideType) as Void

Pop the current View from the View stack.

pushView(view as WatchUi.Views, delegate as WatchUi.InputDelegates or Null, transition as WatchUi.SlideType) as Void

Push a View onto the View stack.

requestUpdate() as Void

Request a call to the onUpdate() method for the current View.

showActionMenu(menu as WatchUi.ActionMenu, delegate as WatchUi.ActionMenuDelegate) as Void

Push an action menu to the display.

showToast(text as Lang.String or Lang.ResourceId, options as { :icon as WatchUi.BitmapResource or Graphics.BitmapReference or Lang.ResourceId} or Null) as Void

Push a toast notification to the display.

startUserReview(token as WatchUi.ReviewResponseToken) as Void

Start the app review UI flow.

switchToView(view as WatchUi.Views, delegate as WatchUi.InputDelegates or Null, transition as WatchUi.SlideType) as Void

Pop the current View from the View stack and push a new one.

## Typedef Details

### InputDelegates as WatchUi.InputDelegate or WatchUi.BehaviorDelegate or WatchUi.ConfirmationDelegate or WatchUi.MenuInputDelegate or WatchUi.NumberPickerDelegate or WatchUi.PickerDelegate or WatchUi.TextPickerDelegate or WatchUi.WatchFaceDelegate or WatchUi.Menu2InputDelegate or WatchUi.ViewLoopDelegate

### Resource as Lang.Array or Lang.Dictionary or Lang.String or WatchUi.AnimationResource or WatchUi.BitmapResource or WatchUi.FontResource or Graphics.BitmapReference or Graphics.FontReference

### TouchEventSettings as { :enabled as Lang.Boolean }

### Views as WatchUi.View or WatchUi.Menu or WatchUi.TextPicker or WatchUi.ProgressBar or WatchUi.Confirmation or WatchUi.NumberPicker or WatchUi.ViewLoop

## Instance Method Details

### animate(object as Lang.Object, property as Lang.Symbol, type as WatchUi.AnimationType, start as Lang.Numeric, stop as Lang.Numeric, period as Lang.Numeric, callback as Null or Lang.Method() as Void) as Void

Animate an Object.

Animate works by changing an object property over time, such as the x-position of a Drawable. The animation starts after the call and runs the length of the specified period. During this time, the View object's onUpdate() method will be invoked at an increased rate to facilitate animation.

Note:

Will cause an app crash if called from background or data field app, or from watch face while in low power mode

### cancelAllAnimations() as Void

Cancel animations started with WatchUi.animate()

Stop all animations that were started with WatchUi.animate(). This will leave all animations at their final frame, as if WatchUi.animate() ran to completion.

### configureTouchEvents(options as WatchUi.TouchEventSettings) as Lang.Boolean

Configurate touch event settings, only allowed for Watch Apps and Audio Content Providers when running in the foreground mode.

### getCurrentView() as [ WatchUi.View or Null, WatchUi.InputDelegates or Null ]

Get the current view that is displayed in the UI

### getSubscreen() as Graphics.BoundingBox or Null

Get the subscreen area in the display.

### getTouchEventsConfiguration() as WatchUi.TouchEventSettings

Returns the current touch event settings.

### loadResource(resource as Lang.ResourceId) as WatchUi.Resource

Load a resource from the executable.

Note:

Toybox::Graphics::BitmapReference and Toybox::Graphics::FontReference are returned for Toybox::WatchUi::BitmapResource and Toybox::WatchUi::FontResource in CIQ 4.0.0 and later.

### makeReviewTokenRequest(callback as Lang.Method(responseStatus as WatchUi.ReviewRequestStatus, token as WatchUi.ReviewResponseToken or Null) as Void) as Void

Initiate a request to ask for this app to be reviewed

### popView(transition as WatchUi.SlideType) as Void

Pop the current View from the View stack.

### pushView(view as WatchUi.Views, delegate as WatchUi.InputDelegates or Null, transition as WatchUi.SlideType) as Void

Push a View onto the View stack.

### requestUpdate() as Void

Request a call to the onUpdate() method for the current View.

### showActionMenu(menu as WatchUi.ActionMenu, delegate as WatchUi.ActionMenuDelegate) as Void

Push an action menu to the display

Note:

An action menu will dismiss it self on either user selecting a menu item or pressing back button.

### showToast(text as Lang.String or Lang.ResourceId, options as { :icon as WatchUi.BitmapResource or Graphics.BitmapReference or Lang.ResourceId } or Null) as Void

Push a toast notification to the display

### startUserReview(token as WatchUi.ReviewResponseToken) as Void

Start the app review UI flow

### switchToView(view as WatchUi.Views, delegate as WatchUi.InputDelegates or Null, transition as WatchUi.SlideType) as Void

Pop the current View from the View stack and push a new one.

Note:

Prior to ConnectIQ 3.1, this method only supported switching to user-defined View objects, and would only accept InputDelegate or BehaviorDelegate objects as delegates for the given View.

---

Generated Jun 8, 2026, 3:42:18 PM

2. Toybox.WatchUi.KeyEvent
   URL: https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/KeyEvent.html
   Toybox.WatchUi.KeyEvent

# Class: Toybox.WatchUi.KeyEvent

Inherits: Toybox.Lang.Object

Toybox.Lang.Object

Toybox.WatchUi.KeyEvent

show all

## Overview

KeyEvent is an object sent to an InputDelegate when a physical button on the device is pressed.

## See Also:

Toybox.WatchUi.InputDelegate

## Instance Method Summary collapse

getKey() as WatchUi.Key

Get the key value of this event.

getType() as WatchUi.KeyPressType

Get the type of click event.

## Instance Method Details

### getKey() as WatchUi.Key

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html#Key-module

Get the key value of this event.

### getType() as WatchUi.KeyPressType

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html#KeyPressType-module

Get the type of click event.

---

Generated Jun 8, 2026, 3:42:18 PM

3. skills/garmin-dev/references/connect-iq-docs/reference/api/watchui.md
   URL: https://github.com/athitupakan/garmin-dev-skills/blob/main/skills/garmin-dev/references/connect-iq-docs/reference/api/watchui.md
   # skills/garmin-dev/references/connect-iq-docs/reference/api/watchui.md

- Branch: main
- Repository: athitupakan/garmin-dev-skills

---

---
source: https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html
sdk: 9.1.0
fetched: 2026-05-30
generated: auto-converted from SDK doc/Toybox/WatchUi.html via _refresh/htmlmd.js — faithful mirror, not hand-curated
---

# Module: Toybox.WatchUi

## Overview

The WatchUi module contains user interface elements available within apps.

WatchUi provides several classes that represent Views, or what is displayed on the screen of a device. Also available are UI elements like on-screen menus, progress bars, buttons, and various pickers. More abstract classes represent all drawable objects, such as bitmaps and text.

Note:

All keys in the key types enum listed after EXTENDED_KEYS (16) were added after ConnectIQ version 1.1.2. Before evaluating these keys, check for the availability of these keys with a `has` check: if (Toybox.WatchUi has :EXTENDED_KEYS) ...

**Since:** API Level 1.0.0

**App Types and Runtime Contexts:**

- Audio Content Provider
- Background (supported since API Level 5.1.0)
- Data Field
- Glance
- Watch App
- Watch Face
- Widget

## Classes Under Namespace

**Classes:** ActionMenu, ActionMenuDelegate, ActionMenuItem, AnimationDelegate, AnimationLayer, AnimationResource, BehaviorDelegate, Bitmap, BitmapResource, Button, CheckboxMenu, CheckboxMenuItem, ClickEvent, ComplicationDrawableRef, Confirmation, ConfirmationDelegate, CustomMenu, CustomMenuItem, DataField, DataFieldAlert, DragEvent, Drawable, FlickEvent, FontResource, GlanceView, GlanceViewDelegate, IconMenuItem, InputDelegate, InvalidMenuItemTypeException, InvalidPointException, InvalidSelectableStateException, KeyEvent, Layer, MapMarker, MapPolyline, MapTrackView, MapView, Menu, Menu2, Menu2InputDelegate, MenuInputDelegate, MenuItem, NumberPicker, NumberPickerDelegate, Picker, PickerDelegate, PickerFactory, ProgressBar, ReviewResponseToken, Selectable, SelectableEvent, SimpleDataField, SwipeEvent, Text, TextArea, TextPicker, TextPickerDelegate, ToggleMenuItem, TransparentProgressBar, View, ViewLoop, ViewLoopDelegate, ViewLoopFactory, WatchFace, WatchFaceDelegate, WatchFacePowerInfo

## Constant Summary

### Key

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| KEY_POWER | 0 | API Level 1.0.0 | The power key |
| KEY_LIGHT | 1 | API Level 1.0.0 | The light key |
| KEY_ZIN | 2 | API Level 1.0.0 | The zoom in key |
| KEY_ZOUT | 3 | API Level 1.0.0 | The zoom out key |
| KEY_ENTER | 4 | API Level 1.0.0 | The enter key |
| KEY_ESC | 5 | API Level 1.0.0 | The escape key |
| KEY_FIND | 6 | API Level 1.0.0 | The find key |
| KEY_MENU | 7 | API Level 1.0.0 | The menu key |
| KEY_DOWN | 8 | API Level 1.0.0 | The down key |
| KEY_DOWN_LEFT | 9 | API Level 1.0.0 | The down left key |
| KEY_DOWN_RIGHT | 10 | API Level 1.0.0 | The down key |
| KEY_LEFT | 11 | API Level 1.0.0 | The left key |
| KEY_RIGHT | 12 | API Level 1.0.0 | The right key |
| KEY_UP | 13 | API Level 1.0.0 | The up key |
| KEY_UP_LEFT | 14 | API Level 1.0.0 | The up-left |
| KEY_UP_RIGHT | 15 | API Level 1.0.0 | The up-right key |
| EXTENDED_KEYS | 16 | API Level 1.1.2 | Indicates extended key support |
| KEY_PAGE | 17 | API Level 1.1.2 | The page key |
| KEY_START | 18 | API Level 1.1.2 | The start key |
| KEY_LAP | 19 | API Level 1.1.2 | The lap key |
| KEY_RESET | 20 | API Level 1.1.2 | The reset key |
| KEY_SPORT | 21 | API Level 1.1.2 | The sport key |
| KEY_CLOCK | 22 | API Level 1.1.2 | The clock key |
| KEY_MODE | 23 | API Level 1.1.2 | The mode key |
| KEY_ACTION_MENU | 24 | API Level 5.1.1 | The action menu key |

### AnimationType

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ANIM_TYPE_LINEAR | 0 | API Level 1.0.0 | Animation with a constant speed |
| ANIM_TYPE_EASE_IN | 1 | API Level 1.0.0 | Animation that increases in speed from start to end |
| ANIM_TYPE_EASE_OUT | 2 | API Level 1.0.0 | Animation that decreases in speed from start to end |
| ANIM_TYPE_EASE_IN_OUT | 3 | API Level 1.0.0 | Animation that increases in speed from the start, then decreases in speed toward the end |

### KeyPressType

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| PRESS_TYPE_DOWN | 0 | API Level 1.1.2 | The key is pressed down |
| PRESS_TYPE_UP | 1 | API Level 1.1.2 | The key is released |
| PRESS_TYPE_ACTION | 2 | API Level 1.1.2 | The key's action is performed |

### ClickType

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CLICK_TYPE_TAP | 0 | API Level 1.0.0 | A tap on the screen |
| CLICK_TYPE_HOLD | 1 | API Level 1.0.0 | A press and hold on the screen |
| CLICK_TYPE_RELEASE | 2 | API Level 1.0.0 | A release of a hold on the screen |

### MapMarkerIcon

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| MAP_MARKER_ICON_PIN | 0 | API Level 3.0.0 | The default Garmin map marker pin icon |

### MapMode

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| MAP_MODE_PREVIEW | 0 | API Level 3.0.0 | The preview mode for a MapView |
| MAP_MODE_BROWSE | 1 | API Level 3.0.0 | The browse mode for a MapView |

### SwipeDirection

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| SWIPE_UP | 0 | API Level 1.0.0 | A swipe in the upward direction |
| SWIPE_RIGHT | 1 | API Level 1.0.0 | A swipe towards the right |
| SWIPE_DOWN | 2 | API Level 1.0.0 | A swipe in the downward direction |
| SWIPE_LEFT | 3 | API Level 1.0.0 | A swipe towards the left |

### DragType

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| DRAG_TYPE_START | 0 | API Level 3.3.0 | Start of a screen drag |
| DRAG_TYPE_CONTINUE | 1 | API Level 3.3.0 | Continuation of a screen drag |
| DRAG_TYPE_STOP | 2 | API Level 3.3.0 | Stop of a screen drag |

### ControlBarLeftButton

**Since:** API Level 4.1.2

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CONTROL_BAR_LEFT_BUTTON_BACK | 0 | API Level 4.1.2 | |
| CONTROL_BAR_LEFT_BUTTON_CANCEL | 1 | API Level 4.1.2 | |

### ControlBarRightButton

**Since:** API Level 4.1.2

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CONTROL_BAR_RIGHT_BUTTON_ACCEPT | 2 | API Level 4.1.2 | |
| CONTROL_BAR_RIGHT_BUTTON_MENU | 3 | API Level 4.1.2 | |

### AnalogClockState

Set the state for analog clock hands

**Since:** API Level 3.3.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ANALOG_CLOCK_STATE_RESTING | 0 | API Level 3.3.0 | Set the clock hands to resting position |
| ANALOG_CLOCK_STATE_SYSTEM_TIME | 1 | API Level 3.3.0 | Set the clock hands to system time |
| ANALOG_CLOCK_STATE_HOLDING | 2 | API Level 3.3.0 | Set the clock hands to the specified position |

### WatchFaceConfigType

WatchFace config types.

**Since:** API Level 5.1.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| WATCH_FACE_CONFIG_TYPE_STYLE | 0 | API Level 5.1.0 | |
| WATCH_FACE_CONFIG_TYPE_COMPLICATION | 1 | API Level 5.1.0 | |
| WATCH_FACE_CONFIG_TYPE_ACCENT_COLOR | 2 | API Level 5.1.0 | |
| WATCH_FACE_CONFIG_TYPE_COMPLICATION_COLOR | 3 | API Level 5.1.0 | |

### MenuTheme

Menu theme for supported devices

**Since:** API Level 4.1.8

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| MENU_THEME_DEFAULT | 0 | API Level 4.1.8 | The default theme color as specified by the device. |
| MENU_THEME_BLUE | 1 | API Level 4.1.8 | |
| MENU_THEME_CYAN | 2 | API Level 4.1.8 | |
| MENU_THEME_GREEN | 3 | API Level 4.1.8 | |
| MENU_THEME_YELLOW | 4 | API Level 4.1.8 | |
| MENU_THEME_ORANGE | 5 | API Level 4.1.8 | |
| MENU_THEME_RED | 6 | API Level 4.1.8 | |
| MENU_THEME_PINK | 7 | API Level 4.1.8 | |
| MENU_THEME_PURPLE | 8 | API Level 4.1.8 | |
| MENU_THEME_GREEN_YELLOW | 9 | API Level 4.1.8 | |

### Confirm

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| CONFIRM_NO | 0 | API Level 1.0.0 | |
| CONFIRM_YES | 1 | API Level 1.0.0 | |

### NumberPickerMode

 **This has been deprecated**

This enum may be removed after System 3.

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| NUMBER_PICKER_DISTANCE | 0 | API Level 1.0.0 | A Float in meters (m) |
| NUMBER_PICKER_TIME | 1 | API Level 1.0.0 | A Duration |
| NUMBER_PICKER_TIME_MIN_SEC | 2 | API Level 1.0.0 | A Duration |
| NUMBER_PICKER_TIME_OF_DAY | 3 | API Level 1.0.0 | A Duration representing the number of seconds since midnight |
| NUMBER_PICKER_WEIGHT | 4 | API Level 1.0.0 | A Float in kilograms (kg) |
| NUMBER_PICKER_HEIGHT | 5 | API Level 1.0.0 | A Float in meters (m) |
| NUMBER_PICKER_CALORIES | 6 | API Level 1.0.0 | A Number |
| NUMBER_PICKER_BIRTH_YEAR | 7 | API Level 1.0.0 | A Number |

### SlideType

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| SLIDE_IMMEDIATE | 0 | API Level 1.0.0 | No transition. |
| SLIDE_LEFT | 1 | API Level 1.0.0 | The View slides to the left. |
| SLIDE_RIGHT | 2 | API Level 1.0.0 | The View slides to the right. |
| SLIDE_DOWN | 3 | API Level 1.0.0 | The View slides down. |
| SLIDE_UP | 4 | API Level 1.0.0 | The View slides up. |
| SLIDE_BLINK | 5 | API Level 3.1.0 | The View fades in. |

### LayoutVerticalAlignment

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| LAYOUT_VALIGN_TOP | -0x7FFFFFFF | API Level 1.2.0 | Set a Drawable object's locY property to this to align it to the top edge of the device context (Dc). |
| LAYOUT_VALIGN_BOTTOM | -0x7FFFFFFE | API Level 1.2.0 | Set a Drawable object's locY property to this to align it to the bottom edge of the device context (Dc). |
| LAYOUT_VALIGN_CENTER | -0x7FFFFFFD | API Level 1.2.0 | Set a Drawable object's locY property to this to center it vertically in the device context (Dc). |
| LAYOUT_VALIGN_START | -0x7FFFFFFC | API Level 1.2.0 | Set a Drawable object's locY property to this to make it equal to its parent's locY property. |

### LayoutHorizontalAlignment

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| LAYOUT_HALIGN_LEFT | -0x7FFFFFFF | API Level 1.2.0 | Set a Drawable object's locX property to this to align it along the left edge of the device context (Dc). |
| LAYOUT_HALIGN_RIGHT | -0x7FFFFFFE | API Level 1.2.0 | Set a Drawable object's locX property to this to align it along the right edge of the device context (Dc). |
| LAYOUT_HALIGN_CENTER | -0x7FFFFFFD | API Level 1.2.0 | Set a Drawable object's locX property to this to center it horizontally in the device context (Dc). |
| LAYOUT_HALIGN_START | -0x7FFFFFFC | API Level 1.2.0 | Set a Drawable object's locX property to this to make it equal to its parent's locX property. |

### AnimationEvent

**Since:** API Level 1.0.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ANIMATION_EVENT_COMPLETE | 0 | API Level 3.1.0 | Indicates the completion of an animation. |
| ANIMATION_EVENT_CANCELED | 1 | API Level 3.1.0 | Indicates the cancel of the animation playback |

### ActionMenuTheme

The theme for the ActionMenu

**Since:** API Level 3.4.0

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| ACTION_MENU_THEME_DARK | 0 | API Level 3.4.0 | Dark theme for the action menu |
| ACTION_MENU_THEME_LIGHT | 1 | API Level 3.4.0 | Light theme for the action menu |

### ReviewRequestStatus

Enum class for makeReviewTokenRequest return status

**Since:** API Level 3.4.2

| Name | Value | Since | Description |
| --- | --- | --- | --- |
| REVIEW_REQUEST_STATUS_GRANTED | 0 | API Level 3.4.2 | |
| REVIEW_REQUEST_STATUS_DENIED | 1 | API Level 3.4.2 | |
| REVIEW_REQUEST_STATUS_FAILED | 2 | API Level 3.4.2 | |

## Typedef Summary
- **InputDelegates** as WatchUi.InputDelegate or WatchUi.BehaviorDelegate or WatchUi.ConfirmationDelegate or WatchUi.MenuInputDelegate or WatchUi.NumberPickerDelegate or WatchUi.PickerDelegate or WatchUi.TextPickerDelegate or WatchUi.WatchFaceDelegate or WatchUi.Menu2InputDelegate or WatchUi.ViewLoopDelegate
- **Resource** as Lang.Array or Lang.Dictionary or Lang.String or WatchUi.AnimationResource or WatchUi.BitmapResource or WatchUi.FontResource or Graphics.BitmapReference or Graphics.FontReference
- **TouchEventSettings** as { :enabled as Lang.Boolean }
- **Views** as WatchUi.View or WatchUi.Menu or WatchUi.TextPicker or WatchUi.ProgressBar or WatchUi.Confirmation or WatchUi.NumberPicker or WatchUi.ViewLoop

## Instance Method Summary
- **animate**(object as Lang.Object, property as Lang.Symbol, type as WatchUi.AnimationType, start as Lang.Numeric, stop as Lang.Numeric, period as Lang.Numeric, callback as **Null** or Lang.Method() as **Void**) as **Void** Animate an Object.
- **cancelAllAnimations**() as **Void** Cancel animations started with WatchUi.animate() Stop all animations that were started with WatchUi.animate().
- **configureTouchEvents**(options as WatchUi.TouchEventSettings) as Lang.Boolean Configurate touch event settings, only allowed for Watch Apps and Audio Content Providers when running in the foreground mode.
- **getCurrentView**() as [ WatchUi.View or **Null**, WatchUi.InputDelegates or **Null** ] Get the current view that is displayed in the UI.
- **getSubscreen**() as Graphics.BoundingBox or **Null** Get the subscreen area in the display.
- **getTouchEventsConfiguration**() as WatchUi.TouchEventSettings Returns the current touch event settings.
- **loadResource**(resource as Lang.ResourceId) as WatchUi.Resource Load a resource from the executable.
- **makeReviewTokenRequest**(callback as Lang.Method(responseStatus as WatchUi.ReviewRequestStatus, token as WatchUi.ReviewResponseToken or **Null**) as **Void**) as **Void** Initiate a request to ask for this app to be reviewed.
- **popView**(transition as WatchUi.SlideType) as **Void** Pop the current View from the View stack.
- **pushView**(view as WatchUi.Views, delegate as WatchUi.InputDelegates or **Null**, transition as WatchUi.SlideType) as **Void** Push a View onto the View stack.
- **requestUpdate**() as **Void** Request a call to the onUpdate() method for the current View.
- **showActionMenu**(menu as WatchUi.ActionMenu, delegate as WatchUi.ActionMenuDelegate) as **Void** Push an action menu to the display.
- **showToast**(text as Lang.String or Lang.ResourceId, options as { :icon as WatchUi.BitmapResource or Graphics.BitmapReference or Lang.ResourceId } or **Null**) as **Void** Push a toast notification to the display.
- **startUserReview**(token as WatchUi.ReviewResponseToken) as **Void** Start the app review UI flow.
- **switchToView**(view as WatchUi.Views, delegate as WatchUi.InputDelegates or **Null**, transition as WatchUi.SlideType) as **Void** Pop the current View from the View stack and push a new one.

## Typedef Details

### `InputDelegates as WatchUi.InputDelegate or WatchUi.BehaviorDelegate or WatchUi.ConfirmationDelegate or WatchUi.MenuInputDelegate or WatchUi.NumberPickerDelegate or WatchUi.PickerDelegate or WatchUi.TextPickerDelegate or WatchUi.WatchFaceDelegate or WatchUi.Menu2InputDelegate or WatchUi.ViewLoopDelegate`

**Since:** API Level 1.0.0

### `Resource as Lang.Array or Lang.Dictionary or Lang.String or WatchUi.AnimationResource or WatchUi.BitmapResource or WatchUi.FontResource or Graphics.BitmapReference or Graphics.FontReference`

**Since:** API Level 1.0.0

### `TouchEventSettings as { :enabled as Lang.Boolean }`

**Since:** API Level 1.0.0

### `Views as WatchUi.View or WatchUi.Menu or WatchUi.TextPicker or WatchUi.ProgressBar or WatchUi.Confirmation or WatchUi.NumberPicker or WatchUi.ViewLoop`

**Since:** API Level 1.0.0

## Instance Method Details

### `animate(object as Lang.Object, property as Lang.Symbol, type as WatchUi.AnimationType, start as Lang.Numeric, stop as Lang.Numeric, period as Lang.Numeric, callback as Null or Lang.Method() as Void) as Void`

Animate an Object.

Animate works by changing an object property over time, such as the x-position of a Drawable. The animation starts after the call and runs the length of the specified period. During this time, the View object's onUpdate() method will be invoked at an increased rate to facilitate animation.

Note:

Will cause an app crash if called from background or data field app, or from watch face while in low power mode

**Parameters:**
- object — (Lang.Object) — The object to animate
- property — (Lang.Symbol) — The Symbol of the object's property to animate (e.g. :locX, :locY, etc.)
- type — (WatchUi.AnimationType) — A WatchUi.ANIM_TYPE_* value
- start — (Lang.Number) — The starting value of the property
- stop — (Lang.Number) — The ending value of the property
- period — (Lang.Float) — The duration of the animation in seconds
- callback — (Lang.Method) — A Method to call when the animation is complete; this can be `null`

**Example:**
Move a bitmap across the screen from left to right

```
using System.WatchUi;

square = new Ui.Bitmap({
    :rezId=>Rez.Drawables.square,
    :locX=>10,
    :locY=>30
});
WatchUi.animate(square, :locX, Ui.ANIM_TYPE_LINEAR, 10, 200, 10, null);
```

**See Also:**

- Toybox.WatchUi.Drawable
- Toybox.WatchUi.Bitmap

**Since:** API Level 1.0.0

### `cancelAllAnimations() as Void`

Cancel animations started with WatchUi.animate()

Stop all animations that were started with WatchUi.animate(). This will leave all animations at their final frame, as if WatchUi.animate() ran to completion.

**See Also:**

- WatchUi.animate()

**Since:** API Level 3.1.7

### `configureTouchEvents(options as WatchUi.TouchEventSettings) as Lang.Boolean`

Configurate touch event settings, only allowed for Watch Apps and Audio Content Providers when running in the foreground mode.

**Parameters:**
- options — (Lang.Dictionary) — Dictionary of touch event settings. :enabled — (Lang.Boolean) — Master flag to enable or disable touch events while application is running in the foreground.

_Supported on 39 devices._

**Returns:**
- Lang.Boolean — True if the operation was successful, false otherwise.

**Since:** API Level 5.2.0

**Throws:**
- (Lang.OperationNotAllowedException) — if called by application type that is not Watch App or Audio Content Provider, or called in background mode.
- (Lang.InvalidValueException) — If invalid options are provided.

### `getCurrentView() as [ WatchUi.View or Null, WatchUi.InputDelegates or Null ]`

Get the current view that is displayed in the UI

**Returns:**
- Lang.Array — An array containing the view and the delegate.

**Since:** API Level 3.4.0

### `getSubscreen() as Graphics.BoundingBox or Null`

Get the subscreen area in the display.

_Supported on 7 devices._

**Returns:**
- Graphics.BoundingBox — object or `null` if no subscreen is present or if a virtual subscreen is present but not used for normal views.

**Since:** API Level 3.2.7

### `getTouchEventsConfiguration() as WatchUi.TouchEventSettings`

Returns the current touch event settings.

_Supported on 39 devices._

**Returns:**
- Lang.Dictionary — Current touch event settings.

**Since:** API Level 5.2.0

### `loadResource(resource as Lang.ResourceId) as WatchUi.Resource`

Load a resource from the executable.

Note:

Toybox::Graphics::BitmapReference and Toybox::Graphics::FontReference are returned for Toybox::WatchUi::BitmapResource and Toybox::WatchUi::FontResource in CIQ 4.0.0 and later.

**Parameters:**
- resource — (Lang.ResourceId) — An identifier for a resource defined in the project's `resources.xml` file

**Example:**
Loading a String resource

```
// The resources.xml file contents:
// <resources>
//     <string id="AppName">APEELingApp</string>
// </resources>
using Toybox.WatchUi;

var banana = WatchUi.loadResource(Rez.Strings.AppName);
```

**Returns:**
- Lang.Array, Lang.Dictionary, Lang.String, WatchUi.AnimationResource, WatchUi.BitmapResource, WatchUi.FontResource, Graphics.BitmapReference, Graphics.FontReference

**Since:** API Level 1.0.0

### `makeReviewTokenRequest(callback as Lang.Method(responseStatus as WatchUi.ReviewRequestStatus, token as WatchUi.ReviewResponseToken or Null) as Void) as Void`

Initiate a request to ask for this app to be reviewed

**Parameters:**
- callback — (Lang.Method) — Callback to invoke when the review token request has completed.

_Supported on 75 devices._

**Since:** API Level 3.4.2

### `popView(transition as WatchUi.SlideType) as Void`

Pop the current View from the View stack.

**Parameters:**
- transition — (WatchUi.SlideType) — A WatchUi.SLIDE_* value

**Since:** API Level 1.0.0

**Throws:**
- (Lang.OperationNotAllowedException) — Thrown if called from background, data field, glance, or watch face app; or of called from the base page of a widget

### `pushView(view as WatchUi.Views, delegate as WatchUi.InputDelegates or Null, transition as WatchUi.SlideType) as Void`

Push a View onto the View stack.

**Parameters:**
- view — (WatchUi.View) — View to push
- delegate — (WatchUi.BehaviorDelegate, WatchUi.ConfirmationDelegate, WatchUi.InputDelegate, WatchUi.MenuInputDelegate, WatchUi.NumberPickerDelegate, WatchUi.PickerDelegate, WatchUi.TextPickerDelegate, WatchUi.WatchFaceDelegate) — The input delegate to handle input for the View
- transition — (WatchUi.SlideType) — A WatchUi.SLIDE_* value

**Since:** API Level 1.0.0

**Throws:**
- (Lang.UnexpectedTypeException) — Thrown when view is type MapView and the visible map area parameters are invalid
- (Lang.OperationNotAllowedException) — Thrown if called from background, data field, glance, or watch face app; or if the new view is a DataField, a GlanceView, or a WatchFace

### `requestUpdate() as Void`

Request a call to the onUpdate() method for the current View.

**See Also:**

- View.onUpdate()

**Since:** API Level 1.0.0

### `showActionMenu(menu as WatchUi.ActionMenu, delegate as WatchUi.ActionMenuDelegate) as Void`

Push an action menu to the display

Note:

An action menu will dismiss it self on either user selecting a menu item or pressing back button.

**Parameters:**
- menu — (WatchUi.ActionMenu) — An action menu object.
- delegate — (WatchUi.ActionMenuDelegate) — An action menu delegate object.

_Supported on 87 devices._

**Since:** API Level 3.4.0

### `showToast(text as Lang.String or Lang.ResourceId, options as { :icon as WatchUi.BitmapResource or Graphics.BitmapReference or Lang.ResourceId } or Null) as Void`

Push a toast notification to the display

**Parameters:**
- text — (Lang.String, Lang.ResourceId) — The text to display in the notification toast.
- options — (Lang.Dictionary) — A Dictionary of options. :icon — (Graphics.BitmapReference, WatchUi.BitmapResource, Lang.ResourceId) — The icon to display with this notification. If no icon is provided and the system requires an icon for a toast, the app icon will be used.

_Supported on 95 devices._

**Since:** API Level 3.4.0

### `startUserReview(token as WatchUi.ReviewResponseToken) as Void`

Start the app review UI flow

**Parameters:**
- token — (WatchUi.ReviewResponseToken) — The token that was passed as a parameter to a successful call to the callback parameter in makeReviewTokenRequest.

_Supported on 75 devices._

**Since:** API Level 3.4.2

**Throws:**
- (Lang.OperationNotAllowedException) — if `token` is not a ReviewResponseToken.

### `switchToView(view as WatchUi.Views, delegate as WatchUi.InputDelegates or Null, transition as WatchUi.SlideType) as Void`

Pop the current View from the View stack and push a new one.

Note:

Prior to ConnectIQ 3.1, this method only supported switching to user-defined View objects, and would only accept InputDelegate or BehaviorDelegate objects as delegates for the given View.

**Parameters:**
- view — (WatchUi.View) — The View object to push
- delegate — (WatchUi.BehaviorDelegate, WatchUi.InputDelegate) — The input delegate to handle input for the View
- transition — (WatchUi.SlideType) — A WatchUi.SLIDE_* value

**Since:** API Level 1.0.0

**Throws:**
- (Lang.OperationNotAllowedException) — Thrown if called from background, data field, glance, or watch face app; or of called from the base page of a widget and the new view is native; or if the new view is a DataField, a GlanceView, or a WatchFace

4. Toybox.WatchUi.InputDelegate
   URL: https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/InputDelegate.html
   Toybox.WatchUi.InputDelegate

# Class: Toybox.WatchUi.InputDelegate

Inherits: Toybox.Lang.Object

Toybox.Lang.Object

Toybox.WatchUi.InputDelegate

show all

## Overview

InputDelegate handles basic input events.

There are four types of basic inputs InputDelegate can handle:

Key, represented by KeyEvent

Touch, represented by ClickEvent

Swipe, represented by SwipeEvent

Selectable, represented by SelectableEvent

This class is the base class for BehaviorDelegate, which goes beyond simple key and screen-based input.

## See Also:

Toybox.WatchUi.BehaviorDelegate

## Direct Known Subclasses

WatchUi.BehaviorDelegate

## Instance Method Summary collapse

onDrag(dragEvent as WatchUi.DragEvent) as Lang.Boolean

A touch screen drag event has occurred.

onFlick(flickEvent as WatchUi.FlickEvent) as Lang.Boolean

A touch screen flick event has occurred.

onHold(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

A touch screen hold event has occurred.

onKey(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

A physical button has been pressed and released.

onKeyPressed(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

A physical button has been pressed down.

onKeyReleased(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

A physical button has been released.

onRelease(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

A touch screen release event has occurred.

onSelectable(selectableEvent as WatchUi.SelectableEvent) as Lang.Boolean

The state of a Selectable has changed.

onSwipe(swipeEvent as WatchUi.SwipeEvent) as Lang.Boolean

A touch screen swipe event has occurred.

onTap(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

A screen tap event has occurred.

## Instance Method Details

### onDrag(dragEvent as WatchUi.DragEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/DragEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A touch screen drag event has occurred.

This is sent when the touch screen is dragged.

### onFlick(flickEvent as WatchUi.FlickEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/FlickEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A touch screen flick event has occurred.

This is sent when the touch screen is flicked.

### onHold(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/ClickEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A touch screen hold event has occurred.

This is sent when the touch screen is touched and not released.

### onKey(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/KeyEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A physical button has been pressed and released.

To find out which key was pressed, use KeyEvent.getKey() to get the button's WatchUi.KEY_* enum value.

### onKeyPressed(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/KeyEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A physical button has been pressed down.

To find out which key was pressed, use KeyEvent.getKey() to get the button's WatchUi.KEY_* enum value.

### onKeyReleased(keyEvent as WatchUi.KeyEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/KeyEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A physical button has been released.

To find out which key was pressed, use KeyEvent.getKey() to get the button's WatchUi.KEY_* enum value.

### onRelease(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/ClickEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A touch screen release event has occurred.

This is only sent after an onHold() event, once the hold on the touch screen is released.

### onSelectable(selectableEvent as WatchUi.SelectableEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/SelectableEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

The state of a Selectable has changed.

### onSwipe(swipeEvent as WatchUi.SwipeEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/SwipeEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A touch screen swipe event has occurred.

This is sent when the touch screen is swiped.

### onTap(clickEvent as WatchUi.ClickEvent) as Lang.Boolean

https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/ClickEvent.html https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Boolean.html

A screen tap event has occurred.

This is sent when the touch screen is tapped (a quick touch and release).

---

Generated Jun 8, 2026, 3:42:18 PM

5. NumpadView.mc at main · bombsimon/garmin-touch-keypad
   URL: https://github.com/bombsimon/garmin-touch-keypad/blob/main/NumpadView.mc
   # File: bombsimon/garmin-touch-keypad/NumpadView.mc

- Repository: bombsimon/garmin-touch-keypad | A barrel to display a numpad and read user input | 2 stars | Monkey C
- Branch: main

```mc
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.Math;
import Toybox.System;
import Toybox.WatchUi;

//! TouchKeypad is a barrel that allows you to show a keypad for touch devices
//! where the user can input a value and pass it back to your desired callback.
//!
//! It is customizable in a way so it can be used for whole numbers, decimal
//! numbers, time etc.
//!
//! Example:
//!
//!   import Toybox.Lang;
//!   import Toybox.WatchUi;
//!
//!   import TouchKeypad;
//!
//!   class myDelegate extends WatchUi.BehaviorDelegate {
//!       function initialize() {
//!           BehaviorDelegate.initialize();
//!       }
//!
//!       function onMenu() as Boolean {
//!           var view = new NumpadView({
//!               // Callback when pressing OK
//!               :callback => method(:myCallback),
//!               // Default value upon showing the numpad.
//!               :input => "98.2",
//!               // Separator within the number, default to `.`
//!               :separator => ".",
//!               // Limit of how many separators might be entered, default to 1
//!               :separatorLimit => 1,
//!           });
//!           var delegate = new NumpadDelegate(view);
//!
//!           WatchUi.pushView(view, delegate, WatchUi.SLIDE_UP);
//!
//!           return true;
//!       }
//!
//!       function myCallback(input as String) as Void {
//!           System.println("Got input: " + input);
//!       }
//!   }
module TouchKeypad {
    const CLEAR = "C";
    const REMOVE = "<";
    const OK = "OK";

    //! The NumpadView is a view that renders the touch keypad and allows the
    //! user to enter a value.
    class NumpadView extends WatchUi.View {
        // Input stores the state of the input being entered. It's empty by
        // default but can be set to a starting value in the initializer.
        private var _input as String = "";

        // Optional callback passed by the user. If the callback is passed, the
        // current input value will be sent when pressing "OK" before popping
        // the view.
        private var _callback as (Method(value as String) as Void)?;

        // Separator is defaulted to a `.` and limited to 1 occurrance. This
        // fits well for numeric values with fractions. If the numpad is used to
        // enter time, a separator of `:` and a limit of 2 makes more sense. If
        // no separator is allowed, setting an empty string will not render the
        // separator button at all.
        private var _separator as String = ".";
        private var _separatorLimit as Number = 1;

        // Vibration will make the device vibrate when touching the screen if a
        // button is hit.
        private var _vibrate as Boolean = true;

        // The size of the buttons, their spacing and starting position is all
        // calculated based on the device's width and height. These are just
        // initialized values since we don't allow null values but will be
        // changed on the first update.
        private var _buttonWidth as Number = 0;
        private var _buttonHeight as Number = 0;
        private var _buttonSpacing as Number = 0;
        private var _buttonXStart as Number = 0;
        private var _buttonYStart as Number = 0;

        // The buttons to render.
        var _buttons as Array<Array<String> > = [
            ["7", "8", "9", ""],
            ["4", "5", "6", REMOVE],
            ["1", "2", "3", OK],
            [_separator, "0", CLEAR, ""],
        ];

        public function initialize(
            settings as
                {
                    :callback as (Method(input as String) as Void),
                    :input as String,
                    :separator as String,
                    :separatorLimit as Number,
                    :vibrate as Boolean,
                }
        ) {
            View.initialize();

            if (settings.hasKey(:callback)) {
                _callback =
                    settings.get(:callback) as
                    (Method(value as String) as Void);
            }

            if (settings.hasKey(:input)) {
                _input = settings.get(:input) as String;
            }

            if (settings.hasKey(:separator)) {
                _separator = settings.get(:separator) as String;
                _buttons[3][0] = _separator;
            }

            if (settings.hasKey(:separatorLimit)) {
                _separatorLimit = settings.get(:separatorLimit) as Number;
            }

            if (settings.hasKey(:vibrate)) {
                _vibrate = settings.get(:vibrate) as Boolean;
            }
        }

        function onUpdate(dc as Dc) {
            dc.clear();

            var width = dc.getWidth();
            var height = dc.getHeight();

            // If no button width is set we assume no values for rendering is
            // set so we compute the button width, height, spacing etc.
            if (_buttonWidth == 0) {
                _buttonWidth = width / 6;
                _buttonHeight = height / 6;
                _buttonSpacing = _buttonWidth / 8;
                _buttonXStart = _buttonWidth;
                _buttonYStart = _buttonHeight;
            }

            dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
            dc.drawText(
                width / 2,
                15,
                Graphics.FONT_XTINY,
                _input,
                Graphics.TEXT_JUSTIFY_CENTER
            );

            dc.setPenWidth(width / 80);
            dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);

            for (var row = 0; row < _buttons.size(); row++) {
                for (var col = 0; col < _buttons[row].size(); col++) {
                    var label = _buttons[row][col];
                    if (label.equals("")) {
                        continue;
                    }

                    var x =
                        _buttonXStart + col * (_buttonWidth + _buttonSpacing);
                    var y =
                        _buttonYStart + row * (_buttonHeight + _buttonSpacing);

                    dc.drawRoundedRectangle(
                        x,
                        y,
                        _buttonWidth,
                        _buttonHeight,
                        width / 20
                    );

                    dc.drawText(
                        x + _buttonWidth / 2,
                        y + _buttonHeight / 2,
                        Graphics.FONT_XTINY,
                        label,
                        Graphics.TEXT_JUSTIFY_CENTER |
                            Graphics.TEXT_JUSTIFY_VCENTER
                    );
                }
            }
        }

        function onTap(position as WatchUi.ClickEvent) as Boolean {
            var button = getButtonAtPosition(position);

            if (button == null) {
                return false;
            }

            if (Attention has :vibrate && _vibrate) {
                Attention.vibrate([new Attention.VibeProfile(25, 50)]);
            }

            if (button.equals(OK)) {
                if (_callback != null) {
                    _callback.invoke(_input);
                }

                WatchUi.popView(WatchUi.SLIDE_DOWN);
            } else if (button.equals(CLEAR)) {
                _input = "";
            } else if (button.equals(REMOVE)) {
                if (_input.length() < 1) {
                    return false;
                }

                _input = _input.substring(0, _input.length() - 1) as String;
            } else {
                if (button.equals(_separator) && _separatorLimit > 0) {
                    var chars = _input.toCharArray();
                    var seenSeparatorChars = 0;

                    for (var i = 0; i < chars.size(); i++) {
                        if (chars[i].toString().equals(_separator)) {
                            seenSeparatorChars += 1;
                        }

                        if (seenSeparatorChars >= _separatorLimit) {
                            return false;
                        }
                    }
                }

                _input += button;
            }

            WatchUi.requestUpdate();

            return true;
        }

        // Determine which button (if any) was tapped
        function getButtonAtPosition(event as WatchUi.ClickEvent) as String? {
            var position = event.getCoordinates();

            for (var row = 0; row < _buttons.size(); row++) {
                for (var col = 0; col < _buttons[row].size(); col++) {
                    var x =
                        _buttonXStart + col * (_buttonWidth + _buttonSpacing);
                    var y =
                        _buttonYStart + row * (_buttonHeight + _buttonSpacing);

                    if (
                        position[0] >= x &&
                        position[0] <= x + _buttonWidth &&
                        position[1] >= y &&
                        position[1] <= y + _buttonHeight
                    ) {
                        return _buttons[row][col];
                    }
                }
            }

            return null;
        }
    }
}

```

6. Monkey Documentation
   URL: https://regal-internet-brothers.github.io/monkey/docs/Programming_Key%20codes.html
   Monkey Documentation

# Key codes

The following constants are for use with KeyDown and KeyHit:

`KEY_BACKSPACE``KEY_TAB``KEY_ENTER``KEY_ESCAPE``KEY_SPACE``KEY_SHIFT``KEY_CONTROL``KEY_PAGEUP``KEY_PAGEDOWN``KEY_END``KEY_HOME``KEY_LEFT``KEY_UP``KEY_RIGHT``KEY_DOWN``KEY_INSERT``KEY_DELETE``KEY_F1``KEY_F2``KEY_F3``KEY_F4``KEY_F5``KEY_F6``KEY_F7``KEY_F8``KEY_F9``KEY_F10``KEY_F11``KEY_F12``KEY_0``KEY_1``KEY_2``KEY_3``KEY_4``KEY_5``KEY_6``KEY_7``KEY_8``KEY_9``KEY_A``KEY_B``KEY_C``KEY_D``KEY_E``KEY_F``KEY_G``KEY_H``KEY_I``KEY_J``KEY_K``KEY_L``KEY_M``KEY_N``KEY_O``KEY_P``KEY_Q``KEY_R``KEY_S``KEY_T``KEY_U``KEY_V``KEY_W``KEY_X``KEY_Y``KEY_Z``KEY_TILDE``KEY_MINUS``KEY_EQUALS``KEY_OPENBRACKET``KEY_CLOSEBRACKET``KEY_BACKSLASH``KEY_SEMICOLON``KEY_QUOTES``KEY_COMMA``KEY_PERIOD``KEY_SLASH``KEY_NUM0``KEY_NUM1``KEY_NUM2``KEY_NUM3``KEY_NUM4``KEY_NUM5``KEY_NUM6``KEY_NUM7``KEY_NUM8``KEY_NUM9``KEY_NUMMULTIPLY``KEY_NUMADD``KEY_NUMSLASH``KEY_NUMSUBTRACT``KEY_NUMDECIMAL``KEY_NUMDIVIDE`

As a convenience, the commands KeyDown and KeyHit can also be used to test non-keyboard devices using these additional constants:

`KEY_LMB``'Left mouse button``KEY_RMB``'Right mouse button``KEY_MMB``'Middle mouse button``KEY_JOY0_A``'A button on joystick 0``KEY_JOY0_B``'B button on joystick 0``KEY_JOY0_X``'X button on joystick 0``KEY_JOY0_Y``'Y button on joystick 0``KEY_JOY0_LEFT``'left button on joystick 0``KEY_JOY0_UP``'up button on joystick 0``KEY_JOY0_RIGHT``'right button on joystick 0``KEY_JOY0_DOWN``'down button on joystick 0``KEY_TOUCH0``'First touch - note: 32 touch codes supported. KEY_TOUCHn=KEY_TOUCH0+n, where n>=0 and n<32`

The following constants are for use with MouseDown and MouseHit:

`MOUSE_LEFT``MOUSE_RIGHT``MOUSE_MIDDLE`

The following constants are for use with JoyDown and JoyHit:

`JOY_A``JOY_B``JOY_X``JOY_Y``JOY_LB``JOY_RB``JOY_BACK``JOY_START``JOY_LEFT``JOY_UP``JOY_RIGHT``JOY_DOWN``JOY_LSB``JOY_RSB``JOY_MENU`

The following constants are for use with GetChar:

`CHAR_TAB``CHAR_BACKSPACE``CHAR_ENTER``CHAR_ESCAPE``CHAR_PAGEUP``CHAR_PAGEDOWN``CHAR_END``CHAR_HOME``CHAR_LEFT``CHAR_UP``CHAR_RIGHT``CHAR_DOWN``CHAR_INSERT``CHAR_DELETE`

7. Monkey Documentation
   URL: https://regal-internet-brothers.github.io/monkey/docs/Modules_mojo.input.html
   Monkey Documentation

# Module mojo.input

The input module allows programs to check for user input from a wide variety of devices such keyboards, mice, joysticks and touchsceens. More...

---

- AccelX : Float ()
- AccelY : Float ()
- AccelZ : Float ()
- DisableKeyboard : Int ()
- EnableKeyboard : Int ()
- GetChar : Int ()
- JoyDown : Int ( button:Int, unit:Int=0 )
- JoyHit : Int ( button:Int, unit:Int=0 )
- JoyX : Float ( index:Int=0, unit:Int=0 )
- JoyY : Float ( index:Int=0, unit:Int=0 )
- JoyZ : Float ( index:Int=0, unit:Int=0 )
- KeyDown : Int ( key:Int )
- KeyHit : Int ( key:Int )
- MouseDown : Int ( button:Int )
- MouseHit : Int ( button:Int )
- MouseX : Float ()
- MouseY : Float ()
- PeekChar : Int ( index:Int )
- TouchDown : Int ( index:Int )
- TouchHit : Int ( index:Int )
- TouchX : Float ( index:Int )
- TouchY : Float ( index:Int )

| Imports: |
| --- |
| Functions: |

## Detailed Discussion

The input module allows programs to check for user input from a wide variety of devices such keyboards, mice, joysticks and touchsceens.

The input module uses a 'polling' input model, meaning that your program must continually check (or 'poll') the state of input devices. Polling should be performed during the OnUpdate phase of your program.

Please see the Key codes page for a full list of keyboard, mouse and joystick constants.

---

## Function Documentation

Function AccelX : Float ()

Returns the x compononent of the acceleration applied to the device, as measured by the device's accelerometer if present.

The value returned is in the range -1 to 1 inclusive.

If the device has no accelerometer, 0 is returned.

Accelerometer functionality is currently only available on the android, html5 and ios targets.

Function AccelY : Float ()

Returns the y compononent of the acceleration applied to the device, as measured by the device's accelerometer if present.

The value returned is in the range -1 to 1 inclusive.

If the device has no accelerometer, 0 is returned.

Accelerometer functionality is currently only available on the andriod, html5 and ios targets.

Function AccelZ : Float ()

Returns the z compononent of the acceleration applied to the device, as measured by the device's accelerometer if present.

The value returned is in the range -1 to 1 inclusive.

If the device has no accelerometer, 0 is returned.

Accelerometer functionality is currently only available on the android,html5 and ios targets.

Function DisableKeyboard : Int ()

On the android and ios targets, this function disables the native virtual keyboard. On all other targets, both EnableKeyboard and DisableKeyboard have no effect.

Function EnableKeyboard : Int ()

On the android and ios targets, this function enables the native virtual keyboard. On all other targets, both EnableKeyboard and DisableKeyboard have no effect.

A virtual keyboard is a graphical representation of a keyboard overlaid on the display that allows users to enter text by means of touching symbols representing keys.

After enabling the virtual keyboard, you program will be able to use GetChar to receive keystrokes, just as if there were a real keyboard present. It is up to the program to eventually call DisableKeyboard when appropriate, for example, when GetChar returns 13 (ie: the 'Enter' key) or 27 (ie: the 'Esc' key).

On the GLFW, HTML5, Flash and XNA (Windows) targets, keyboard support is always assumed to be available and your program can always use GetChar to receive keystrokes.

On the XNA XBOX and Windows Phone 7 targets, keyboard support is currently unavailable.

Function GetChar : Int ()

Returns the character code of the next character in the keyboard character queue, or 0 if no more characters are available. The character is removed from the keyboard character queue.

The keyboard queue contains characters codes as opposed to the key codes used by KeyDown and KeyUp. Character codes differ from key codes in that they are generally printable and may be modified by the shift, control and alt keys. Character codes also 'repeat' at a rate determined by the OS.

The mapping from key codes to character codes is controlled by the underlying OS, but in practice will generally map to ASCII codes.

The input module also provides special character code mappings for a number of unprintable keys:

CHAR_TAB, CHAR_BACKSPACE, CHAR_ENTER, CHAR_ESCAPE, CHAR_PAGEUP, CHAR_PAGEDOWN, CHAR_END, CHAR_HOME, CHAR_LEFT, CHAR_UP, CHAR_RIGHT, CHAR_DOWN, CHAR_INSERT, CHAR_DELETE

`Import``mojo``Class``MyApp``Extends``App``Field``text``$=``"Type something:"``Method``OnCreate``()``SetUpdateRate``30``End``Method``OnUpdate``()``Repeat``Local``char``=``GetChar``()``If``Not``char``Exit``If``char``>=``32``text``+=``String.FromChar``( ``char`` )``Endif``Forever``End``Method``OnRender``()``Cls``DrawText``text``,``0``,``0``End``End``Function``Main``()``New``MyApp``End`

Function JoyDown : Int ( button:Int, unit:Int=0 )

Return 1 if the specified joystick button is currently held down, else 0.

The button parameter should be one of the following constants:

| Joystick button | Description |
| --- | --- |
| JOY_A | 'A' on Xbox 360 controller, 'Cross' on PS3 |
| JOY_B | 'B' on Xbox 360 controller, 'Circle' on PS3 |
| JOY_X | 'X' on XBox 360 controller, 'Square' on PS3 |
| JOY_Y | 'Y' on XBox 360 controller, 'Triangle' on PS3 |
| JOY_LB | Left shoulder button |
| JOY_RB | Right Shoulder button |
| JOY_BACK | 'Back' on Xbox 360 controller, 'Select' on PS3 |
| JOY_START | Start button |
| JOY_LEFT | Directional pad Left button |
| JOY_UP | Directional pad Up button |
| JOY_RIGHT | Directional pad Right button |
| JOY_DOWN | Directional pad Down button |
| JOY_LSB | Left stick button |
| JOY_RSB | Right stick button |
| JOY_MENU | Menu button |

Function JoyHit : Int ( button:Int, unit:Int=0 )

Return the number of times the specified joystick button has been pressed since the last OnUpdate.

The button parameter should be one of the following constants:

| Joystick button | Description |
| --- | --- |
| JOY_A | 'A' on Xbox 360 controller, 'Cross' on PS3 |
| JOY_B | 'B' on Xbox 360 controller, 'Circle' on PS3 |
| JOY_X | 'X' on XBox 360 controller, 'Square' on PS3 |
| JOY_Y | 'Y' on XBox 360 controller, 'Triangle' on PS3 |
| JOY_LB | Left shoulder button |
| JOY_RB | Right Shoulder button |
| JOY_BACK | 'Back' on Xbox 360 controller, 'Select' on PS3 |
| JOY_START | Start button |
| JOY_LEFT | Directional pad Left button |
| JOY_UP | Directional pad Up button |
| JOY_RIGHT | Directional pad Right button |
| JOY_DOWN | Directional pad Down button |
| JOY_LSB | Left stick button |
| JOY_RSB | Right stick button |
| JOY_MENU | Menu button |

Function JoyX : Float ( index:Int=0, unit:Int=0 )

Returns the x, or horizontal, state of a joystick.

The return value will be in the range -1 to +1, with -1 representing 'left' and +1 representing 'right'.

In the case of controllers with 2 joysticks, the index parameter should be 0 for the left hand joystick, or 1 for the right hand joystick.

Note: On the XNA target, JoyX, JoyY and JoyZ will all return 0 until a joystick button is pressed. This is to comply with xbox live publishing guidelines that state that it must be possible to use any of the 4 controllers to play a game. Mojo will therefore wait until a button is pressed (usually in response to a 'press button to start' style message on the title page) before deciding which controller is in use.

Function JoyY : Float ( index:Int=0, unit:Int=0 )

Returns the y, or vertical, state of a joystick.

The return value will be in the range -1 to +1, with -1 representing 'down' and +1 representing 'up'.

In the case of controllers with 2 joysticks, the index parameter should be 0 for the left hand joystick, or 1 for the right hand joystick.

Note: On the XNA target, JoyX, JoyY and JoyZ will all return 0 until a joystick button is pressed. This is to comply with xbox live publishing guidelines that state that it must be possible to use any of the 4 controllers to play a game. Mojo will therefore wait until a button is pressed (usually in response to a 'press button to start' style message on the title page) before deciding which controller is in use.

Function JoyZ : Float ( index:Int=0, unit:Int=0 )

On Playstation/Xbox style controllers, JoyZ returns the state of the analog shoulder controls.

The returned value will be in the range 0 to 1, with 0 indicating 'unpressed' and 1 indicating 'fully pressed'.

The index parameter should be 0 for the left handler shoulder control, or 1 for the right hand shoulder control.

Note: On the XNA target, JoyX, JoyY and JoyZ will all return 0 until a joystick button is pressed. This is to comply with xbox live publishing guidelines that state that it must be possible to use any of the 4 controllers to play a game. Mojo will therefore wait until a controller button is pressed (usually in response to a 'press button to start' style message on the title page) before deciding which controller is in use.

Function KeyDown : Int ( key:Int )

Returns 1 if the specified key is currently held down, otherwise 0.

See also Key codes, KeyHit

Function KeyHit : Int ( key:Int )

Returns the number of times the specified key has been hit since the last OnUpdate.

Note that any on/off style 'buttons' on any device can be read using the KeyDown and KeyHit commands. For example, to read the state of the left mouse button you can use KeyDown( KEY_LMB ) in addition to MouseDown( MOUSE_LEFT ).

See also Key codes, KeyDown

`Import``mojo``Class``MyApp``Extends``App``Field``lineY``Method``OnCreate``()``lineY``=``DeviceHeight``()/``2``SetUpdateRate``30``End``Method``OnUpdate``()``Local``hit``=``KeyHit``( ``KEY_LMB`` ) ``'Uses KeyHit to check the left mouse button. You could also use MouseHit( MOUSE_LEFT )``If``hit``And``MouseY``()<``lineY``Print``"You clicked above the line."``Else``If``hit``And``MouseY``()>=``lineY``Print``"You clicked on or below the line."``End``End``Method``OnRender``()``Cls``DrawLine``0``,``lineY``,``DeviceWidth``(),``lineY``End``End``Function``Main``()``New``MyApp``End`

Function MouseDown : Int ( button:Int )

Returns 1 if the specified mouse button is currently held down, otherwise 0.

The button parameter should be one of:

| Mouse button | Description |
| --- | --- |
| MOUSE_LEFT | Left mouse button |
| MOUSE_RIGHT | Right mouse button |
| MOUSE_MIDDLE | Middle mouse button |

Function MouseHit : Int ( button:Int )

Returns the number of times the specified mouse button has been pressed since the last OnUpdate.

The button parameter should be one of:

| Mouse button | Description |
| --- | --- |
| MOUSE_LEFT | Left mouse button |
| MOUSE_RIGHT | Right mouse button |
| MOUSE_MIDDLE | Middle mouse button |

Function MouseX : Float ()

Returns the x coordinate of the mouse pointer.

On devices with a touch screen but no mouse, MouseX will instead return TouchX( 0 ).

See also MouseY, TouchX

`Import``mojo``Class``MyApp``Extends``App``Method``OnCreate``()``SetUpdateRate``30``End``Method``OnUpdate``()``End``Method``OnRender``()``Cls``DrawText``"MouseX="``+``MouseX``+``", MouseY="``+``MouseY``,``0``,``0``DrawCircle``MouseX``,``MouseY``,``10``End``End``Function``Main``()``New``MyApp``End`

Function MouseY : Float ()

Returns the y coordinate of the mouse pointer.

On devices with a touch screen but no mouse, MouseY will instead return TouchY( 0 ).

See also MouseX, TouchY

Function PeekChar : Int ( index:Int )

Returns the character of the character at the specified index in the keyboard character queue. The character is NOT removed from the keyboard character queue.

If there is no character at the specified index, 0 is returned.

Function TouchDown : Int ( index:Int )

Returns 1 if the finger specified by index is currently touching the touchscreen, otherwise 0.

Note that index refers to the order touches have been made. The first finger to touch the touchscreen will be assigned index 0. If another finger then also touches the touchscreen, it will be assigned index 1 and so on.

If a finger is touching, you can get its x and y coordinates using the TouchX and TouchY commands.

On devices with a mouse but no touch screen, TouchDown( 0 ) will instead return MouseDown( MOUSE_LEFT ).

See also TouchX, TouchY, TouchHit, MouseDown

`Import``mojo``Class``MyApp``Extends``App``Field``touching``Method``OnCreate``()``SetUpdateRate``30``End``Method``OnUpdate``()``touching``=``0``For``Local``i``=``0``Until``32``If``TouchDown``( ``i`` ) ``touching``+=``1``Next``End``Method``OnRender``()``Cls``DrawText``touching``,``0``,``0``End``End``Function``Main``()``New``MyApp``End`

Function TouchHit : Int ( index:Int )

Returns the number of times the specified finger has made contact with the touchscreen since the last OnUpdate.

Note that index refers to the order touches have been made. The first finger to touch the touchscreen will be assigned index 0. If another finger then also touches the touchscreen, it will be assigned index 1 and so on.

If a finger is touching, you can get its x and y coordinates using the TouchX and TouchY commands.

On devices with a mouse but no touch screen, TouchHit( 0 ) will instead return MouseHit( MOUSE_LEFT ).

See also TouchX, TouchY, TouchDown, MouseHit

Function TouchX : Float ( index:Int )

Returns the x coordinate of the finger on a touch screen device.

Note that index refers to the order touches have been made. The first finger to touch the touchscreen will be assigned index 0. If another finger then also touches the touchscreen, it will be assigned index 1 and so on.

On devices with a mouse but no touch screen, TouchX( 0 ) will instead return MouseX.

See also TouchY, TouchHit, TouchDown, MouseX

Function TouchY : Float ( index:Int )

Returns the y coordinate of the finger on a touch screen device.

Note that index refers to the order touches have been made. The first finger to touch the touchscreen will be assigned index 0. If another finger then also touches the touchscreen, it will be assigned index 1 and so on.

On devices with a mouse but no touch screen, TouchY( 0 ) will instead return MouseY.

See also TouchX, TouchDown, TouchHit, MouseY

---

8. KeyStateEnums - Kanzi Engine Lua
   URL: https://docs.kanzi.com/4.0.0/en/reference/kanzi-lua-api/module/KeyStateEnums.html
   KeyStateEnums - Kanzi Engine Lua

Kanzi Engine Lua API

## Module KeyStateEnums ¶

## KeyState ¶

Indicates the states of a hardware key.

The key is pressed.

The key is released.

| Pressed¶ |
| --- |
| Released¶ |

KeyStateEnums - Kanzi Engine Lua
[Kanzi Engine Lua API](../index.html)
[![](../img/i-left.svg?7de174c)Previous](../module/EchoModeEnums.html)
[Next![](../img/i-right.svg?7de174c)](../module/NodeEnums.html)
![](../../_static/favicon96x96.png)Ask AI
Contents
* [Module `KeyStateEnums`](#KeyStateEnums)
* [KeyState](#KeyState)
Manual
* [Introduction](../index.html)
Classes
* [Action](../class/Action.html)
* [ActionBase](../class/ActionBase.html)
* [ActionBaseMetadata](../class/ActionBaseMetadata.html)
* [ActionMetadata](../class/ActionMetadata.html)
* [Activity2D](../class/Activity2D.html)
* [Activity2DMetadata](../class/Activity2DMetadata.html)
* [Activity3D](../class/Activity3D.html)
* [Activity3DMetadata](../class/Activity3DMetadata.html)
* [ActivityCodeBehind](../class/ActivityCodeBehind.html)
* [ActivityCodeBehindMetadata](../class/ActivityCodeBehindMetadata.html)
* [ActivityConceptMetadata](../class/ActivityConceptMetadata.html)
* [ActivityElementMetadata](../class/ActivityElementMetadata.html)
* [ActivityHostConceptMetadata](../class/ActivityHostConceptMetadata.html)
* [AnimationBindingProcessor](../class/AnimationBindingProcessor.html)
* [AnimationBindingProcessorMetadata](../class/AnimationBindingProcessorMetadata.html)
* [AnimationPlayer](../class/AnimationPlayer.html)
* [AnimationPlayerMetadata](../class/AnimationPlayerMetadata.html)
* [ApplyAction](../class/ApplyAction.html)
* [ApplyActionMetadata](../class/ApplyActionMetadata.html)
* [ApplyActivationAction](../class/ApplyActivationAction.html)
* [ApplyActivationActionMetadata](../class/ApplyActivationActionMetadata.html)
* [ApplyPropertyAction](../class/ApplyPropertyAction.html)
* [ApplyPropertyActionMetadata](../class/ApplyPropertyActionMetadata.html)
* [BinaryResource](../class/BinaryResource.html)
* [BinaryResourceMetadata](../class/BinaryResourceMetadata.html)
* [BindingProcessor](../class/BindingProcessor.html)
* [BindingProcessorMetadata](../class/BindingProcessorMetadata.html)
* [BitmapFont](../class/BitmapFont.html)
* [BitmapFontMetadata](../class/BitmapFontMetadata.html)
* [BlitRenderPass](../class/BlitRenderPass.html)
* [BlitRenderPassMetadata](../class/BlitRenderPassMetadata.html)
* [BlurEffect2D](../class/BlurEffect2D.html)
* [BlurEffect2DMetadata](../class/BlurEffect2DMetadata.html)
* [Brush](../class/Brush.html)
* [BrushMetadata](../class/BrushMetadata.html)
* [Button2D](../class/Button2D.html)
* [Button2DMetadata](../class/Button2DMetadata.html)
* [Button3D](../class/Button3D.html)
* [Button3DMetadata](../class/Button3DMetadata.html)
* [ButtonConceptMetadata](../class/ButtonConceptMetadata.html)
* [CallbackBindingProcessor](../class/CallbackBindingProcessor.html)
* [CallbackBindingProcessorMetadata](../class/CallbackBindingProcessorMetadata.html)
* [Camera](../class/Camera.html)
* [CameraMetadata](../class/CameraMetadata.html)
* [ClearRenderPass](../class/ClearRenderPass.html)
* [ClearRenderPassMetadata](../class/ClearRenderPassMetadata.html)
* [ClickConceptMetadata](../class/ClickConceptMetadata.html)
* [ClickManipulator](../class/ClickManipulator.html)
* [ClickManipulatorComponent](../class/ClickManipulatorComponent.html)
* [ClickManipulatorComponentMetadata](../class/ClickManipulatorComponentMetadata.html)
* [ClickManipulatorMetadata](../class/ClickManipulatorMetadata.html)
* [CodeBehind](../class/CodeBehind.html)
* [CodeBehindMetadata](../class/CodeBehindMetadata.html)
* [ColorBrush](../class/ColorBrush.html)
* [ColorBrushMetadata](../class/ColorBrushMetadata.html)
* [ColorRGBA](../class/ColorRGBA.html)
* [CommandMetadata](../class/CommandMetadata.html)
* [CompositionBrush](../class/CompositionBrush.html)
* [CompositionBrushMetadata](../class/CompositionBrushMetadata.html)
* [CompositionTargetRenderPass](../class/CompositionTargetRenderPass.html)
* [CompositionTargetRenderPassMetadata](../class/CompositionTargetRenderPassMetadata.html)
* [Condition](../class/Condition.html)
* [ConditionMetadata](../class/ConditionMetadata.html)
* [ConstraintsMetadata](../class/ConstraintsMetadata.html)
* [ContentBrush](../class/ContentBrush.html)
* [ContentBrushMetadata](../class/ContentBrushMetadata.html)
* [ContentLayout2D](../class/ContentLayout2D.html)
* [ContentLayout2DMetadata](../class/ContentLayout2DMetadata.html)
* [ContentLayout3D](../class/ContentLayout3D.html)
* [ContentLayout3DMetadata](../class/ContentLayout3DMetadata.html)
* [ContentLayoutConceptMetadata](../class/ContentLayoutConceptMetadata.html)
* [CubeMapRenderPass](../class/CubeMapRenderPass.html)
* [CubeMapRenderPassMetadata](../class/CubeMapRenderPassMetadata.html)
* [DataContext](../class/DataContext.html)
* [DataContextMetadata](../class/DataContextMetadata.html)
* [DataDrivenExclusiveActivityHost2D](../class/DataDrivenExclusiveActivityHost2D.html)
* [DataDrivenExclusiveActivityHost2DMetadata](../class/DataDrivenExclusiveActivityHost2DMetadata.html)
* [DataDrivenExclusiveActivityHost3D](../class/DataDrivenExclusiveActivityHost3D.html)
* [DataDrivenExclusiveActivityHost3DMetadata](../class/DataDrivenExclusiveActivityHost3DMetadata.html)
* [DataDrivenExclusiveActivityHostConceptMetadata](../class/DataDrivenExclusiveActivityHostConceptMetadata.html)
* [DataObject](../class/DataObject.html)
* [DataObjectBool](../class/DataObjectBool.html)
* [DataObjectBoolMetadata](../class/DataObjectBoolMetadata.html)
* [DataObjectInt](../class/DataObjectInt.html)
* [DataObjectIntMetadata](../class/DataObjectIntMetadata.html)
* [DataObjectListMetadata](../class/DataObjectListMetadata.html)
* [DataObjectMetadata](../class/DataObjectMetadata.html)
* [DataObjectReal](../class/DataObjectReal.html)
* [DataObjectRealMetadata](../class/DataObjectRealMetadata.html)
* [DataObjectString](../class/DataObjectString.html)
* [DataObjectStringMetadata](../class/DataObjectStringMetadata.html)
* [DataSource](../class/DataSource.html)
* [DataSourceListBoxItemGenerator2D](../class/DataSourceListBoxItemGenerator2D.html)
* [DataSourceListBoxItemGenerator2DMetadata](../class/DataSourceListBoxItemGenerator2DMetadata.html)
* [DataSourceListBoxItemGenerator3D](../class/DataSourceListBoxItemGenerator3D.html)
* [DataSourceListBoxItemGenerator3DMetadata](../class/DataSourceListBoxItemGenerator3DMetadata.html)
* [DataSourceMetadata](../class/DataSourceMetadata.html)
* [DataTrigger](../class/DataTrigger.html)
* [DataTriggerComponent](../class/DataTriggerComponent.html)
* [DataTriggerComponentMetadata](../class/DataTriggerComponentMetadata.html)
* [DataTriggerMetadata](../class/DataTriggerMetadata.html)
* [DispatchMessageAction](../class/DispatchMessageAction.html)
* [DispatchMessageActionMetadata](../class/DispatchMessageActionMetadata.html)
* [DockLayout2D](../class/DockLayout2D.html)
* [DockLayout2DMetadata](../class/DockLayout2DMetadata.html)
* [DockLayout3D](../class/DockLayout3D.html)
* [DockLayout3DMetadata](../class/DockLayout3DMetadata.html)
* [DockLayoutConceptMetadata](../class/DockLayoutConceptMetadata.html)
* [DomainMetadata](../class/DomainMetadata.html)
* [DragAndDropManipulator](../class/DragAndDropManipulator.html)
* [DragAndDropManipulatorMetadata](../class/DragAndDropManipulatorMetadata.html)
* [DrawObjectsRenderPass](../class/DrawObjectsRenderPass.html)
* [DrawObjectsRenderPassMetadata](../class/DrawObjectsRenderPassMetadata.html)
* [DrawObjectsWithMaterialRenderPass](../class/DrawObjectsWithMaterialRenderPass.html)
* [DrawObjectsWithMaterialRenderPassMetadata](../class/DrawObjectsWithMaterialRenderPassMetadata.html)
* [EffectStack2D](../class/EffectStack2D.html)
* [EffectStack2DMetadata](../class/EffectStack2DMetadata.html)
* [EmptyNode2D](../class/EmptyNode2D.html)
* [EmptyNode2DMetadata](../class/EmptyNode2DMetadata.html)
* [EmptyNode3D](../class/EmptyNode3D.html)
* [EmptyNode3DMetadata](../class/EmptyNode3DMetadata.html)
* [ExclusiveActivityHost2D](../class/ExclusiveActivityHost2D.html)
* [ExclusiveActivityHost2DMetadata](../class/ExclusiveActivityHost2DMetadata.html)
* [ExclusiveActivityHost3D](../class/ExclusiveActivityHost3D.html)
* [ExclusiveActivityHost3DMetadata](../class/ExclusiveActivityHost3DMetadata.html)
* [ExclusiveActivityHostConceptMetadata](../class/ExclusiveActivityHostConceptMetadata.html)
* [ExecuteLuaAction](../class/ExecuteLuaAction.html)
* [ExecuteLuaActionMetadata](../class/ExecuteLuaActionMetadata.html)
* [ExpressionBindingProcessorMetadata](../class/ExpressionBindingProcessorMetadata.html)
* [ExpressionConditionMetadata](../class/ExpressionConditionMetadata.html)
* [FloatValueAccumulator](../class/FloatValueAccumulator.html)
* [FloatValueAccumulatorMetadata](../class/FloatValueAccumulatorMetadata.html)
* [FlowLayout2D](../class/FlowLayout2D.html)
* [FlowLayout2DMetadata](../class/FlowLayout2DMetadata.html)
* [FlowLayout3D](../class/FlowLayout3D.html)
* [FlowLayout3DMetadata](../class/FlowLayout3DMetadata.html)
* [FlowLayoutConceptMetadata](../class/FlowLayoutConceptMetadata.html)
* [FocusManagerMetadata](../class/FocusManagerMetadata.html)
* [FocusNavigationManipulator](../class/FocusNavigationManipulator.html)
* [FocusNavigationManipulatorMetadata](../class/FocusNavigationManipulatorMetadata.html)
* [FocusScopeCoreMetadata](../class/FocusScopeCoreMetadata.html)
* [Font](../class/Font.html)
* [FontFamily](../class/FontFamily.html)
* [FontFamilyMetadata](../class/FontFamilyMetadata.html)
* [FontMetadata](../class/FontMetadata.html)
* [FontStyleConceptMetadata](../class/FontStyleConceptMetadata.html)
* [ForwardingAction](../class/ForwardingAction.html)
* [ForwardingActionMetadata](../class/ForwardingActionMetadata.html)
* [GPUResource](../class/GPUResource.html)
* [GPUResourceMetadata](../class/GPUResourceMetadata.html)
* [GatherLightsRenderPass](../class/GatherLightsRenderPass.html)
* [GatherLightsRenderPassMetadata](../class/GatherLightsRenderPassMetadata.html)
* [GatherNearestLightsRenderPass](../class/GatherNearestLightsRenderPass.html)
* [GatherNearestLightsRenderPassMetadata](../class/GatherNearestLightsRenderPassMetadata.html)
* [GridLayout2D](../class/GridLayout2D.html)
* [GridLayout2DMetadata](../class/GridLayout2DMetadata.html)
* [GridLayout3D](../class/GridLayout3D.html)
* [GridLayout3DMetadata](../class/GridLayout3DMetadata.html)
* [GridLayoutConceptMetadata](../class/GridLayoutConceptMetadata.html)
* [GridListBox2D](../class/GridListBox2D.html)
* [GridListBox2DMetadata](../class/GridListBox2DMetadata.html)
* [GridListBox3D](../class/GridListBox3D.html)
* [GridListBox3DMetadata](../class/GridListBox3DMetadata.html)
* [GridListBoxConceptMetadata](../class/GridListBoxConceptMetadata.html)
* [Image2D](../class/Image2D.html)
* [Image2DMetadata](../class/Image2DMetadata.html)
* [InputManipulator](../class/InputManipulator.html)
* [InputManipulatorMetadata](../class/InputManipulatorMetadata.html)
* [Instantiator3D](../class/Instantiator3D.html)
* [Instantiator3DMetadata](../class/Instantiator3DMetadata.html)
* [InstructionBindingProcessor](../class/InstructionBindingProcessor.html)
* [InstructionBindingProcessorMetadata](../class/InstructionBindingProcessorMetadata.html)
* [IntValueAccumulator](../class/IntValueAccumulator.html)
* [IntValueAccumulatorMetadata](../class/IntValueAccumulatorMetadata.html)
* [KanziObject](../class/KanziObject.html)
* [KeyManipulator](../class/KeyManipulator.html)
* [KeyManipulatorComponent](../class/KeyManipulatorComponent.html)
* [KeyManipulatorComponentMetadata](../class/KeyManipulatorComponentMetadata.html)
* [KeyManipulatorMetadata](../class/KeyManipulatorMetadata.html)
* [Light](../class/Light.html)
* [LightMetadata](../class/LightMetadata.html)
* [ListBoxConceptMetadata](../class/ListBoxConceptMetadata.html)
* [ListBoxItemContainer2D](../class/ListBoxItemContainer2D.html)
* [ListBoxItemContainer2DMetadata](../class/ListBoxItemContainer2DMetadata.html)
* [ListBoxItemContainer3D](../class/ListBoxItemContainer3D.html)
* [ListBoxItemContainer3DMetadata](../class/ListBoxItemContainer3DMetadata.html)
* [ListBoxItemContainerGenerator3D](../class/ListBoxItemContainerGenerator3D.html)
* [ListBoxItemContainerGenerator3DMetadata](../class/ListBoxItemContainerGenerator3DMetadata.html)
* [ListBoxItemContainerMetadata](../class/ListBoxItemContainerMetadata.html)
* [ListBoxItemGenerator2D](../class/ListBoxItemGenerator2D.html)
* [ListBoxItemGenerator2DMetadata](../class/ListBoxItemGenerator2DMetadata.html)
* [ListBoxItemGenerator3D](../class/ListBoxItemGenerator3D.html)
* [ListBoxItemGenerator3DMetadata](../class/ListBoxItemGenerator3DMetadata.html)
* [ListBoxScrollingConceptMetadata](../class/ListBoxScrollingConceptMetadata.html)
* [LongPressManipulator](../class/LongPressManipulator.html)
* [LongPressManipulatorComponent](../class/LongPressManipulatorComponent.html)
* [LongPressManipulatorComponentMetadata](../class/LongPressManipulatorComponentMetadata.html)
* [LongPressManipulatorMetadata](../class/LongPressManipulatorMetadata.html)
* [LuaDataSource](../class/LuaDataSource.html)
* [LuaDataSourceMetadata](../class/LuaDataSourceMetadata.html)
* [MaskEffect2D](../class/MaskEffect2D.html)
* [MaskEffect2DMetadata](../class/MaskEffect2DMetadata.html)
* [Material](../class/Material.html)
* [MaterialBrush](../class/MaterialBrush.html)
* [MaterialBrushMetadata](../class/MaterialBrushMetadata.html)
* [MaterialMetadata](../class/MaterialMetadata.html)
* [MaterialSetupRenderPass](../class/MaterialSetupRenderPass.html)
* [MaterialSetupRenderPassMetadata](../class/MaterialSetupRenderPassMetadata.html)
* [Matrix3x3](../class/Matrix3x3.html)
* [Matrix4x4](../class/Matrix4x4.html)
* [Mesh](../class/Mesh.html)
* [MeshMetadata](../class/MeshMetadata.html)
* [MessageArguments](../class/MessageArguments.html)
* [MessageArgumentsMetadata](../class/MessageArgumentsMetadata.html)
* [MessageSubscriptionToken](../class/MessageSubscriptionToken.html)
* [MessageTrigger](../class/MessageTrigger.html)
* [MessageTriggerMetadata](../class/MessageTriggerMetadata.html)
* [MessageType](../class/MessageType.html)
* [MetaObjectMetadata](../class/MetaObjectMetadata.html)
* [MipmapGenerationConceptMetadata](../class/MipmapGenerationConceptMetadata.html)
* [Model3D](../class/Model3D.html)
* [Model3DMetadata](../class/Model3DMetadata.html)
* [MoveFocusAction](../class/MoveFocusAction.html)
* [MoveFocusActionMetadata](../class/MoveFocusActionMetadata.html)
* [MultiClickManipulator](../class/MultiClickManipulator.html)
* [MultiClickManipulatorComponent](../class/MultiClickManipulatorComponent.html)
* [MultiClickManipulatorComponentMetadata](../class/MultiClickManipulatorComponentMetadata.html)
* [MultiClickManipulatorMetadata](../class/MultiClickManipulatorMetadata.html)
* [NavigationManipulator](../class/NavigationManipulator.html)
* [NavigationManipulatorComponent](../class/NavigationManipulatorComponent.html)
* [NavigationManipulatorComponentMetadata](../class/NavigationManipulatorComponentMetadata.html)
* [NavigationManipulatorMetadata](../class/NavigationManipulatorMetadata.html)
* [NinePatchImage2D](../class/NinePatchImage2D.html)
* [NinePatchImage2DMetadata](../class/NinePatchImage2DMetadata.html)
* [Node](../class/Node.html)
* [Node2D](../class/Node2D.html)
* [Node2DMetadata](../class/Node2DMetadata.html)
* [Node3D](../class/Node3D.html)
* [Node3DMetadata](../class/Node3DMetadata.html)
* [NodeComponent](../class/NodeComponent.html)
* [NodeComponentMetadata](../class/NodeComponentMetadata.html)
* [NodeEffect2D](../class/NodeEffect2D.html)
* [NodeEffect2DMetadata](../class/NodeEffect2DMetadata.html)
* [NodeEffectPrefab2D](../class/NodeEffectPrefab2D.html)
* [NodeEffectPrefab2DMetadata](../class/NodeEffectPrefab2DMetadata.html)
* [NodeListRenderPass](../class/NodeListRenderPass.html)
* [NodeListRenderPassMetadata](../class/NodeListRenderPassMetadata.html)
* [NodeMetadata](../class/NodeMetadata.html)
* [NullBrush](../class/NullBrush.html)
* [NullBrushMetadata](../class/NullBrushMetadata.html)
* [ObjectMetadata](../class/ObjectMetadata.html)
* [ObjectRef](../class/ObjectRef.html)
* [ObjectSource](../class/ObjectSource.html)
* [ObjectSourceMetadata](../class/ObjectSourceMetadata.html)
* [OnAttachedTrigger](../class/OnAttachedTrigger.html)
* [OnAttachedTriggerMetadata](../class/OnAttachedTriggerMetadata.html)
* [OnPropertyChangedTrigger](../class/OnPropertyChangedTrigger.html)
* [OnPropertyChangedTriggerMetadata](../class/OnPropertyChangedTriggerMetadata.html)
* [OutlineEffect2D](../class/OutlineEffect2D.html)
* [OutlineEffect2DMetadata](../class/OutlineEffect2DMetadata.html)
* [Page](../class/Page.html)
* [PageHost](../class/PageHost.html)
* [PageHostMetadata](../class/PageHostMetadata.html)
* [PageMetadata](../class/PageMetadata.html)
* [PageTransitionCollectionMetadata](../class/PageTransitionCollectionMetadata.html)
* [PanManipulator](../class/PanManipulator.html)
* [PanManipulatorComponent](../class/PanManipulatorComponent.html)
* [PanManipulatorComponentMetadata](../class/PanManipulatorComponentMetadata.html)
* [PanManipulatorMetadata](../class/PanManipulatorMetadata.html)
* [ParallelActivityHost2D](../class/ParallelActivityHost2D.html)
* [ParallelActivityHost2DMetadata](../class/ParallelActivityHost2DMetadata.html)
* [ParallelActivityHost3D](../class/ParallelActivityHost3D.html)
* [ParallelActivityHost3DMetadata](../class/ParallelActivityHost3DMetadata.html)
* [ParallelActivityHostConceptMetadata](../class/ParallelActivityHostConceptMetadata.html)
* [PinchManipulator](../class/PinchManipulator.html)
* [PinchManipulatorMetadata](../class/PinchManipulatorMetadata.html)
* [PipelineStateRenderPass](../class/PipelineStateRenderPass.html)
* [PipelineStateRenderPassMetadata](../class/PipelineStateRenderPassMetadata.html)
* [PortalView](../class/PortalView.html)
* [PortalViewMetadata](../class/PortalViewMetadata.html)
* [PrefabTemplate](../class/PrefabTemplate.html)
* [PrefabTemplateMetadata](../class/PrefabTemplateMetadata.html)
* [PrefabTemplateNode](../class/PrefabTemplateNode.html)
* [PrefabTemplateNodeMetadata](../class/PrefabTemplateNodeMetadata.html)
* [PrefabView2D](../class/PrefabView2D.html)
* [PrefabView2DMetadata](../class/PrefabView2DMetadata.html)
* [PrefabView3D](../class/PrefabView3D.html)
* [PrefabView3DMetadata](../class/PrefabView3DMetadata.html)
* [PrefabViewConceptMetadata](../class/PrefabViewConceptMetadata.html)
* [ProgressiveRenderingViewport2D](../class/ProgressiveRenderingViewport2D.html)
* [ProgressiveRenderingViewport2DMetadata](../class/ProgressiveRenderingViewport2DMetadata.html)
* [PropertyDrivenAnimationPlayer](../class/PropertyDrivenAnimationPlayer.html)
* [PropertyDrivenAnimationPlayerMetadata](../class/PropertyDrivenAnimationPlayerMetadata.html)
* [PropertyTargetEasingInterpolator](../class/PropertyTargetEasingInterpolator.html)
* [PropertyTargetEasingInterpolatorMetadata](../class/PropertyTargetEasingInterpolatorMetadata.html)
* [PropertyTargetInterpolator](../class/PropertyTargetInterpolator.html)
* [PropertyTargetInterpolatorMetadata](../class/PropertyTargetInterpolatorMetadata.html)
* [PropertyType](../class/PropertyType.html)
* [Quaternion](../class/Quaternion.html)
* [RangeAccumulateBindingProcessor](../class/RangeAccumulateBindingProcessor.html)
* [RangeAccumulateBindingProcessorMetadata](../class/RangeAccumulateBindingProcessorMetadata.html)
* [RangeBindingProcessor](../class/RangeBindingProcessor.html)
* [RangeBindingProcessorMetadata](../class/RangeBindingProcessorMetadata.html)
* [RangeConceptMetadata](../class/RangeConceptMetadata.html)
* [RenderPass](../class/RenderPass.html)
* [RenderPassMetadata](../class/RenderPassMetadata.html)
* [RenderPassPrefab](../class/RenderPassPrefab.html)
* [RenderPassPrefabMetadata](../class/RenderPassPrefabMetadata.html)
* [RenderPassView](../class/RenderPassView.html)
* [RenderPassViewMetadata](../class/RenderPassViewMetadata.html)
* [Resource](../class/Resource.html)
* [ResourceBindingProcessor](../class/ResourceBindingProcessor.html)
* [ResourceBindingProcessorMetadata](../class/ResourceBindingProcessorMetadata.html)
* [ResourceDictionary](../class/ResourceDictionary.html)
* [ResourceDictionaryMetadata](../class/ResourceDictionaryMetadata.html)
* [ResourceDictionarySelector](../class/ResourceDictionarySelector.html)
* [ResourceDictionarySelectorMetadata](../class/ResourceDictionarySelectorMetadata.html)
* [ResourceMetadata](../class/ResourceMetadata.html)
* [SRTValue2D](../class/SRTValue2D.html)
* [SRTValue3D](../class/SRTValue3D.html)
* [Scene](../class/Scene.html)
* [SceneMetadata](../class/SceneMetadata.html)
* [Screen](../class/Screen.html)
* [ScreenMetadata](../class/ScreenMetadata.html)
* [ScrollView2D](../class/ScrollView2D.html)
* [ScrollView2DMetadata](../class/ScrollView2DMetadata.html)
* [ScrollView3D](../class/ScrollView3D.html)
* [ScrollView3DMetadata](../class/ScrollView3DMetadata.html)
* [ScrollViewConceptMetadata](../class/ScrollViewConceptMetadata.html)
* [SetPropertyAction](../class/SetPropertyAction.html)
* [SetPropertyActionMetadata](../class/SetPropertyActionMetadata.html)
* [ShaderProgram](../class/ShaderProgram.html)
* [ShaderProgramMetadata](../class/ShaderProgramMetadata.html)
* [ShadowEffect2D](../class/ShadowEffect2D.html)
* [ShadowEffect2DMetadata](../class/ShadowEffect2DMetadata.html)
* [Slider2D](../class/Slider2D.html)
* [Slider2DMetadata](../class/Slider2DMetadata.html)
* [Slider3D](../class/Slider3D.html)
* [Slider3DMetadata](../class/Slider3DMetadata.html)
* [SliderConceptMetadata](../class/SliderConceptMetadata.html)
* [StackLayout2D](../class/StackLayout2D.html)
* [StackLayout2DMetadata](../class/StackLayout2DMetadata.html)
* [StackLayout3D](../class/StackLayout3D.html)
* [StackLayout3DMetadata](../class/StackLayout3DMetadata.html)
* [StackLayoutConceptMetadata](../class/StackLayoutConceptMetadata.html)
* [StandardMaterialMetadata](../class/StandardMaterialMetadata.html)
* [StandardPbrMaterialMetadata](../class/StandardPbrMaterialMetadata.html)
* [StandardPostProcessMaterialMetadata](../class/StandardPostProcessMaterialMetadata.html)
* [StateManager](../class/StateManager.html)
* [StateManagerMetadata](../class/StateManagerMetadata.html)
* [Style](../class/Style.html)
* [StyleMetadata](../class/StyleMetadata.html)
* [Surface](../class/Surface.html)
* [SurfaceMetadata](../class/SurfaceMetadata.html)
* [TextBlock2D](../class/TextBlock2D.html)
* [TextBlock2DMetadata](../class/TextBlock2DMetadata.html)
* [TextBlock3D](../class/TextBlock3D.html)
* [TextBlock3DMetadata](../class/TextBlock3DMetadata.html)
* [TextBlockConceptMetadata](../class/TextBlockConceptMetadata.html)
* [TextBox2D](../class/TextBox2D.html)
* [TextBox2DMetadata](../class/TextBox2DMetadata.html)
* [TextBox3D](../class/TextBox3D.html)
* [TextBox3DMetadata](../class/TextBox3DMetadata.html)
* [TextBoxConceptMetadata](../class/TextBoxConceptMetadata.html)
* [TextBoxMetadata](../class/TextBoxMetadata.html)
* [TextConceptMetadata](../class/TextConceptMetadata.html)
* [TextInputConceptMetadata](../class/TextInputConceptMetadata.html)
* [TextInputManipulator](../class/TextInputManipulator.html)
* [TextInputManipulatorMetadata](../class/TextInputManipulatorMetadata.html)
* [TextResource](../class/TextResource.html)
* [TextResourceMetadata](../class/TextResourceMetadata.html)
* [TextureBrush](../class/TextureBrush.html)
* [TextureBrushMetadata](../class/TextureBrushMetadata.html)
* [TextureMetadata](../class/TextureMetadata.html)
* [TimerTrigger](../class/TimerTrigger.html)
* [TimerTriggerMetadata](../class/TimerTriggerMetadata.html)
* [ToggleButton2D](../class/ToggleButton2D.html)
* [ToggleButton2DMetadata](../class/ToggleButton2DMetadata.html)
* [ToggleButton3D](../class/ToggleButton3D.html)
* [ToggleButton3DMetadata](../class/ToggleButton3DMetadata.html)
* [ToggleButtonGroup2D](../class/ToggleButtonGroup2D.html)
* [ToggleButtonGroup2DMetadata](../class/ToggleButtonGroup2DMetadata.html)
* [ToggleButtonGroup3D](../class/ToggleButtonGroup3D.html)
* [ToggleButtonGroup3DMetadata](../class/ToggleButtonGroup3DMetadata.html)
* [ToggleButtonGroupConceptMetadata](../class/ToggleButtonGroupConceptMetadata.html)
* [Trajectory](../class/Trajectory.html)
* [TrajectoryLayout2D](../class/TrajectoryLayout2D.html)
* [TrajectoryLayout2DMetadata](../class/TrajectoryLayout2DMetadata.html)
* [TrajectoryLayout3D](../class/TrajectoryLayout3D.html)
* [TrajectoryLayout3DMetadata](../class/TrajectoryLayout3DMetadata.html)
* [TrajectoryLayoutConceptMetadata](../class/TrajectoryLayoutConceptMetadata.html)
* [TrajectoryListBox3D](../class/TrajectoryListBox3D.html)
* [TrajectoryListBox3DMetadata](../class/TrajectoryListBox3DMetadata.html)
* [TrajectoryMetadata](../class/TrajectoryMetadata.html)
* [Trigger](../class/Trigger.html)
* [TriggerMetadata](../class/TriggerMetadata.html)
* [TrySetFocusAction](../class/TrySetFocusAction.html)
* [TrySetFocusActionMetadata](../class/TrySetFocusActionMetadata.html)
* [ValueAccumulator](../class/ValueAccumulator.html)
* [ValueAccumulatorMetadata](../class/ValueAccumulatorMetadata.html)
* [ValueControlledExclusiveActivityHostConceptMetadata](../class/ValueControlledExclusiveActivityHostConceptMetadata.html)
* [Vector2](../class/Vector2.html)
* [Vector3](../class/Vector3.html)
* [Vector4](../class/Vector4.html)
* [Viewport2D](../class/Viewport2D.html)
* [Viewport2DMetadata](../class/Viewport2DMetadata.html)
* [Viewport3D](../class/Viewport3D.html)
* [Viewport3DMetadata](../class/Viewport3DMetadata.html)
* [WriteLogAction](../class/WriteLogAction.html)
* [WriteLogActionMetadata](../class/WriteLogActionMetadata.html)
Modules
* [log](../module/log.html)
* [PropertyTargetEasingInterpolatorEnums](../module/PropertyTargetEasingInterpolatorEnums.html)
* [CachingModeEnums](../module/CachingModeEnums.html)
* [Node2DEnums](../module/Node2DEnums.html)
* [GPUResourceMemoryTypeEnums](../module/GPUResourceMemoryTypeEnums.html)
* [KeyModifierEnums](../module/KeyModifierEnums.html)
* [PropertyDataTypeEnums](../module/PropertyDataTypeEnums.html)
* [TouchStateEnums](../module/TouchStateEnums.html)
* [GraphicsStencilOperationEnums](../module/GraphicsStencilOperationEnums.html)
* [PropertyTypeChangeFlagEnums](../module/PropertyTypeChangeFlagEnums.html)
* [GraphicsFormatEnums](../module/GraphicsFormatEnums.html)
* [FontWeightEnums](../module/FontWeightEnums.html)
* [TimerRecurrenceEnums](../module/TimerRecurrenceEnums.html)
* [FocusScopeTypeEnums](../module/FocusScopeTypeEnums.html)
* [FocusChainDirectionEnums](../module/FocusChainDirectionEnums.html)
* [FontHintingPreferenceEnums](../module/FontHintingPreferenceEnums.html)
* [ResourceLoadTaskTypeEnums](../module/ResourceLoadTaskTypeEnums.html)
* [TrajectoryEnums](../module/TrajectoryEnums.html)
* [EffectStack2DEnums](../module/EffectStack2DEnums.html)
* [SelectionBehaviorEnums](../module/SelectionBehaviorEnums.html)
* [PointerStateEnums](../module/PointerStateEnums.html)
* [TouchPointStateEnums](../module/TouchPointStateEnums.html)
* [FontStyleEnums](../module/FontStyleEnums.html)
* [NodeComponentStateEnums](../module/NodeComponentStateEnums.html)
* [DataObjectTypeEnums](../module/DataObjectTypeEnums.html)
* [GraphicsCompareFunctionEnums](../module/GraphicsCompareFunctionEnums.html)
* [PipelineStateRenderPassEnums](../module/PipelineStateRenderPassEnums.html)
* [ScreenEnums](../module/ScreenEnums.html)
* [Matrix4x4Enums](../module/Matrix4x4Enums.html)
* [AnimationEasingModeEnums](../module/AnimationEasingModeEnums.html)
* [SamplerFilterEnums](../module/SamplerFilterEnums.html)
* [KzuTimeLineEntryPlaybackModeEnums](../module/KzuTimeLineEntryPlaybackModeEnums.html)
* [KzuExpressionValidatorOperationEnums](../module/KzuExpressionValidatorOperationEnums.html)
* [PropertyFieldEnums](../module/PropertyFieldEnums.html)
* [InputTypeEnums](../module/InputTypeEnums.html)
* [PropertyNotificationReasonEnums](../module/PropertyNotificationReasonEnums.html)
* [GraphicsCullModeEnums](../module/GraphicsCullModeEnums.html)
* [MemoryStrategyEnums](../module/MemoryStrategyEnums.html)
* [FocusOnPressEnums](../module/FocusOnPressEnums.html)
* [OutlineEffect2DEnums](../module/OutlineEffect2DEnums.html)
* [EchoModeEnums](../module/EchoModeEnums.html)
* [KeyStateEnums](../module/KeyStateEnums.html)
* [NodeEnums](../module/NodeEnums.html)
* [GraphicsColorWriteModeEnums](../module/GraphicsColorWriteModeEnums.html)
* [WindowOrientationEnums](../module/WindowOrientationEnums.html)
* [SamplerAddressingModeEnums](../module/SamplerAddressingModeEnums.html)
* [LayoutDirectionEnums](../module/LayoutDirectionEnums.html)
* [MessageRoutingEnums](../module/MessageRoutingEnums.html)
* [ActivityStatusEnums](../module/ActivityStatusEnums.html)
* [PointerButtonEnums](../module/PointerButtonEnums.html)
* [MaskEffect2DEnums](../module/MaskEffect2DEnums.html)
* [ColorWorkflowEnums](../module/ColorWorkflowEnums.html)
* [MultisampleCountEnums](../module/MultisampleCountEnums.html)
* [SamplerMipmapModeEnums](../module/SamplerMipmapModeEnums.html)
* [InputMethodActionEnums](../module/InputMethodActionEnums.html)
* [CameraEnums](../module/CameraEnums.html)
* [ShadowEffect2DEnums](../module/ShadowEffect2DEnums.html)
* [BlurEffect2DEnums](../module/BlurEffect2DEnums.html)
* [TextKeyNavigationDirectionEnums](../module/TextKeyNavigationDirectionEnums.html)
* [KzuPropertyBinaryTargetAttributeEnums](../module/KzuPropertyBinaryTargetAttributeEnums.html)
* [TaskRecurrenceEnums](../module/TaskRecurrenceEnums.html)
* [FocusStateEnums](../module/FocusStateEnums.html)
* [TextureTypeEnums](../module/TextureTypeEnums.html)
* [LogicalKeyEnums](../module/LogicalKeyEnums.html)
## Module `KeyStateEnums`
[¶](#KeyStateEnums)
## KeyState
[¶](#KeyState)
Indicates the states of a hardware key.
|Pressed[¶](#KeyState.Pressed)|
The key is pressed.
|
|Released[¶](#KeyState.Released)|
The key is released.
|

9. sdk/fidl/fuchsia.ui.input/input_events.fidl - fuchsia - Git at Google
   URL: https://fuchsia.googlesource.com/fuchsia/+/master/sdk/fidl/fuchsia.ui.input/input_events.fidl
   sdk/fidl/fuchsia.ui.input/input\_events.fidl - fuchsia - Git at Google
[![Google Git](https://www.gstatic.com/images/branding/lockups/2x/lockup_git_color_108x24dp.png)](https://fuchsia.googlesource.com/)
[Sign in](https://accounts.google.com/AccountChooser?faa=1&service=gerritcodereview&continue=https://fuchsia.googlesource.com/login/fuchsia/+/refs/heads/main/sdk/fidl/fuchsia.ui.input/input_events.fidl)
[fuchsia](https://fuchsia.googlesource.com/?format=HTML)/[fuchsia](https://fuchsia.googlesource.com/fuchsia/)/[refs/heads/main](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main)/[.](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/)/[sdk](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk)/[fidl](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/fidl)/[fuchsia.ui.input](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/fidl/fuchsia.ui.input)/input\_events.fidl
blob: 3f29330043eee37ad7a06d4f9559125a4cca67ba [[file](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/fidl/fuchsia.ui.input/input_events.fidl)] [[log](https://fuchsia.googlesource.com/fuchsia/+log/refs/heads/main/sdk/fidl/fuchsia.ui.input/input_events.fidl)] [[blame](https://fuchsia.googlesource.com/fuchsia/+blame/refs/heads/main/sdk/fidl/fuchsia.ui.input/input_events.fidl)]
|// Copyright 2014 The Fuchsia Authors. All rights reserved.|
|// Use of this source code is governed by a BSD-style license that can be|
|// found in the LICENSE file.|
|library fuchsia.ui.input;|
||
|@available(deprecated=13)|
|typeKeyboardEventPhase=flexibleenum{|
|/// When key is pressed down.|
|PRESSED=0;|
|/// When key is released.|
|RELEASED=1;|
|/// This key `PRESSED` is not directed to this input client anymore.|
|CANCELLED=2;|
|/// Whether this is an automatically generated key repeat|
|REPEAT=3;|
|};|
||
|/// `KeyboardEvent` represents event generated by a user's interaction with a|
|/// keyboard.|
|///|
|/// Those events are triggered by distinct pressed state changes of the keys.|
|///|
|/// The state transitions should be as follows:|
|/// PRESSED -> (REPEAT ->) RELEASED|
|/// or|
|/// PRESSED -> (REPEAT ->) CANCELLED|
|///|
|/// The input system will repeat those events automatically when a code\_point is|
|/// available.|
|///|
|/// DEPRECATED: Will be removed in favor of `fuchsia.ui.input.KeyEvent`.|
|@available(deprecated=13)|
|typeKeyboardEvent=struct{|
|/// Time the event was delivered. The time is in nanoseconds and corresponds|
|/// to the monotonic time as determined by the zx\_clock\_get\_monotonic syscall.|
|event\_time uint64;|
||
|device\_id uint32;|
||
|phaseKeyboardEventPhase;|
||
|/// Keyboard HID Usage|
|/// See https://www.usb.org/sites/default/files/documents/hut1\_12v2.pdf|
|hid\_usage uint32;|
||
|/// The unicode code point represented by this key event, if any.|
|/// Dead keys are represented as Unicode combining characters.|
|///|
|/// If there is no unicode code point, this value is zero.|
|code\_point uint32;|
||
|/// Key modifiers as defined by the different kModifier constants such as|
|/// `kModifierCapsLock` currently pressed|
|modifiers uint32;|
|};|
||
|@available(deprecated=10,note="Instead, use fuchsia.ui.pointer")|
|typePointerEventType=strictenum{|
|/// A touch-based pointer device.|
|TOUCH=0;|
||
|/// A pointer device with a stylus.|
|STYLUS=1;|
||
|/// A pointer device with a stylus that has been inverted.|
|INVERTED\_STYLUS=2;|
||
|/// A pointer device without a stylus.|
|MOUSE=3;|
|};|
||
|@available(deprecated=10,note="Instead, use fuchsia.ui.pointer")|
|typePointerEventPhase=strictenum{|
|/// The device has started tracking the pointer.|
|///|
|/// For example, the pointer might be hovering above the device, having not yet|
|/// made contact with the surface of the device.|
|ADD=0;|
||
|/// The pointer has moved with respect to the device while not in contact with|
|/// the device.|
|HOVER=1;|
||
|/// The pointer has made contact with the device.|
|///|
|/// For `MOUSE` devices, this is triggered when the primary button is pressed|
|/// down to emulate a touch on the screen.|
|DOWN=2;|
||
|/// The pointer has moved with respect to the device while in contact with the|
|/// device.|
|MOVE=3;|
||
|/// The pointer has stopped making contact with the device.|
|///|
|/// For `MOUSE` devices, this is triggered when the primary button is|
|/// released.|
|UP=4;|
||
|/// The device is no longer tracking the pointer.|
|///|
|/// For example, the pointer might have drifted out of the device's hover|
|/// detection range or might have been disconnected from the system entirely.|
|REMOVE=5;|
||
|/// The input from the pointer is no longer directed towards this receiver.|
|CANCEL=6;|
||
|// TODO: add phases to indicate button press / release|
|};|
||
|/// Pointers represent raw data about the user's interaction with the screen.|
|///|
|/// The state transitions should be as follows:|
|/// ADD (-> HOVER) -> DOWN -> MOVE -> UP (-> HOVER) -> REMOVE|
|///|
|/// At any point after the initial ADD, a transition to CANCEL is also possible.|
|@available(deprecated=10,note="Instead, use fuchsia.ui.pointer")|
|typePointerEvent=struct{|
|/// Time the event was delivered. The time is in nanoseconds and corresponds|
|/// to the monotonic time as determined by the zx\_clock\_get\_monotonic syscall.|
|event\_time uint64;|
||
|device\_id uint32;|
||
|pointer\_id uint32;|
||
|typePointerEventType;|
||
|phasePointerEventPhase;|
||
|/// `x` and `y` are in the coordinate system of the View.|
|x float32;|
|y float32;|
||
|// TODO(jpoichet) float32 vx;|
|// TODO(jpoichet) float32 vy;|
|@allow\_deprecated\_struct\_defaults|
|radius\_major float32=0.0;// DO NOT USE|
|@allow\_deprecated\_struct\_defaults|
|radius\_minor float32=0.0;// DO NOT USE|
|// TODO(jpoichet) float32 orientation;|
|// TODO(jpoichet) float32 tilt;|
|// TODO(jpoichet) float32 altitude;|
|// TODO(jpichet) float32 amplitude;|
||
|/// Currently pressed buttons as defined the kButton constants such as|
|/// `kMousePrimaryButton`|
|buttons uint32;|
|};|
||
|@available(deprecated=10,note="Instead, use fuchsia.ui.views.ViewRefFocused")|
|typeFocusEvent=struct{|
|/// Time the event was delivered. The time is in nanoseconds and corresponds|
|/// to the monotonic time as determined by the zx\_clock\_get\_monotonic syscall.|
|event\_time uint64;|
||
|/// Whether the view has gained input focused or not.|
|focusedbool;|
|};|
||
|typeMediaButtonsEvent=table{|
|1:volume int8;|
|2:mic\_mutebool;|
|3:pausebool;|
|4:camera\_disablebool;|
|@available(added=15)|
|5:powerbool;|
|@available(added=20)|
|6:functionbool;|
|};|
||
|typeInputEvent=strictunion{|
|@available(deprecated=10,note="Instead, use fuchsia.ui.pointer")|
|1:pointerPointerEvent;|
|@available(deprecated=13)|
|2:keyboardKeyboardEvent;|
|@available(deprecated=10,note="Instead, use fuchsia.ui.views.ViewRefFocused")|
|3:focusFocusEvent;|
|};|

10. modules/mojo/app.monkey at 28a83858138f7d7618a7c4c788a5226a7d6a213a · blitz-research/monkey
   URL: https://github.com/blitz-research/monkey/blob/28a83858138f7d7618a7c4c788a5226a7d6a213a/modules/mojo/app.monkey
   # File: blitz-research/monkey/modules/mojo/app.monkey

- Repository: blitz-research/monkey | Blitz Research Monkey Source | 226 stars | C
- Branch: 28a83858138f7d7618a7c4c788a5226a7d6a213a

```monkey

' Module mojo.app
'
' Copyright 2011 Mark Sibly, all rights reserved.
' No warranty implied; use at your own risk.

#If MOJO_VERSION_X
Import mojox.app
#Else

Private

Import graphicsdevice
Import audiodevice
Import inputdevice

Import graphics
Import audio
Import input

Import data

Global _app:App
Global _game:=BBGame.Game()
Global _delegate:GameDelegate
Global _devWidth:Int
Global _devHeight:Int
Global _updateRate:Int
Global _displayModes:DisplayMode[]
Global _desktopMode:DisplayMode

Function EnumDisplayModes:Void()
	Local modes:=_game.GetDisplayModes()
	Local mmap:=New IntMap<DisplayMode>
	Local mstack:=New Stack<DisplayMode>
	For Local i:=0 Until modes.Length
		Local w:=modes[i].width
		Local h:=modes[i].height
		Local size:=w Shl 16 | h
		If mmap.Contains( size )
		Else
			Local mode:=New DisplayMode( modes[i].width,modes[i].height )
			mmap.Insert size,mode
			mstack.Push mode
		Endif
	Next
	_displayModes=mstack.ToArray()
	Local mode:=_game.GetDesktopMode()
	If mode
		_desktopMode=New DisplayMode( mode.width,mode.height )
	Else
		_desktopMode=New DisplayMode( DeviceWidth,DeviceHeight )
	Endif
End

Function ValidateDeviceWindow:Void( notifyApp:Bool )
	Local w:=_game.GetDeviceWidth()
	Local h:=_game.GetDeviceHeight()
	If w=_devWidth And h=_devHeight Return
	_devWidth=w
	_devHeight=h
	If notifyApp _app.OnResize
End

Class GameDelegate Extends BBGameDelegate

	Field _graphics:GraphicsDevice
	Field _audio:AudioDevice
	Field _input:InputDevice

	'***** BBGameDelegate *****

	Method StartGame:Void()

		_graphics=New GraphicsDevice
		graphics.SetGraphicsDevice _graphics
		graphics.SetFont Null

		_audio=New AudioDevice
		audio.SetAudioDevice _audio

		_input=New InputDevice
		input.SetInputDevice _input

		ValidateDeviceWindow False

		EnumDisplayModes

		_app.OnCreate()
	End

	Method SuspendGame:Void()
		_app.OnSuspend()
		_audio.Suspend
	End

	Method ResumeGame:Void()
		_audio.Resume
		_app.OnResume()
	End

	Method UpdateGame:Void()
		ValidateDeviceWindow True
		_input.BeginUpdate
		_app.OnUpdate()
		_input.EndUpdate
	End

	Method RenderGame:Void()
		ValidateDeviceWindow True
		Local mode:=_graphics.BeginRender()
		If mode graphics.BeginRender
		If mode=2 _app.OnLoading Else _app.OnRender
		If mode graphics.EndRender
		_graphics.EndRender
	End

	Method KeyEvent:Void( event:Int,data:Int )
		_input.KeyEvent event,data
		If event<>BBGameEvent.KeyDown Return
		Select data
		Case KEY_CLOSE
			_app.OnClose
		Case KEY_BACK
			_app.OnBack
		End
	End

	Method MouseEvent:Void( event:Int,data:Int,x:Float,y:Float )
		_input.MouseEvent event,data,x,y
	End

	Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float )
		_input.TouchEvent event,data,x,y
	End

	Method MotionEvent:Void( event:Int,data:Int,x:Float,y:Float,z:Float )
		_input.MotionEvent event,data,x,y,z
	End

	Method DiscardGraphics:Void()
		_graphics.DiscardGraphics
	End

End

Public

Class App

	Method New()
		If _app Error "App has already been created"
		_app=Self
		_delegate=New GameDelegate
		_game.SetDelegate _delegate
	End

	Method OnCreate:Int()
	End

	Method OnUpdate:Int()
	End

	Method OnRender:Int()
	End

	Method OnLoading:Int()
	End

	Method OnSuspend:Int()
	End

	Method OnResume:Int()
	End

	Method OnClose:Int()
		EndApp
	End

	Method OnBack:Int()
		OnClose
	End

	Method OnResize:Int()
	End

End

Class DisplayMode

	Method New( width:Int,height:Int )
		_width=width
		_height=height
	End

	Method Width:Int() Property
		Return _width
	End

	Method Height:Int() Property
		Return _height
	End

	Private

	Field _width:Int
	Field _height:Int

End

Function LoadState:String()
	Return _game.LoadState()
End

Function SaveState:Void( state:String )
	_game.SaveState( state )
End

Function LoadString:String( path:String )
	Return _game.LoadString( FixDataPath(path) )
End

Function SetUpdateRate:Void( hertz )
	_updateRate=hertz
	_game.SetUpdateRate hertz
End

Function UpdateRate:Int()
	Return _updateRate
End

Function Millisecs:Int()
	Return _game.Millisecs()
End

Function GetDate:Int[]()
	Local date:Int[7]
	GetDate date
	Return date
End

Function GetDate:Void( date:Int[] )
	_game.GetDate date
End

Function OpenUrl:Void( url:String )
	_game.OpenUrl url
End

Function HideMouse:Void()
	_game.SetMouseVisible False
End

Function ShowMouse:Void()
	_game.SetMouseVisible True
End

Function EndApp:Void()
	Error ""
End

Function DeviceWidth:Int()
	Return _devWidth
End

Function DeviceHeight:Int()
	Return _devHeight
End

Function SetDeviceWindow:Void( width:Int,height:Int,flags:Int )
	_game.SetDeviceWindow( width,height,flags )
	ValidateDeviceWindow False
End

Function SetDisplayMode:Void( width:Int,height:Int,depth:Int,hertz:Int,flags:Int )
	_game.SetDisplayMode width,height,depth,hertz,flags
	ValidateDeviceWindow False
End

Function DisplayModes:DisplayMode[]()
	Return _displayModes
End

Function DesktopMode:DisplayMode()
	Return _desktopMode
End

Function SetSwapInterval:Void( interval:Int )
	_game.SetSwapInterval interval
End

#Endif

```

Toybox.WatchUi

Toybox.WatchUi.KeyEvent

Toybox.WatchUi.InputDelegate

Monkey Documentation

Monkey Documentation

KeyStateEnums - Kanzi Engine Lua