pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Pebble JavaScript API
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
    • Rocky
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

ActionMenu

Function Documentation

char * action_menu_item_get_label(const ActionMenuItem * item)

Getter for the label of a given ActionMenuItem.

Parameters

item

the ActionMenuItem of interest

Returns

a pointer to the string label. NULL if invalid.

void * action_menu_item_get_action_data(const ActionMenuItem * item)

Getter for the action_data pointer of a given ActionMenuitem.

Parameters

item

the ActionMenuItem of interest

Returns

a pointer to the data. NULL if invalid.

See Also

action_menu_level_add_action
ActionMenuLevel * action_menu_level_create(uint16_t max_items)

Create a new action menu level with storage allocated for a given number of items.

Note

levels are freed alongside the whole hierarchy so no destroy API is provided.

by default, levels are using ActionMenuLevelDisplayModeWide. Use action_menu_level_set_display_mode to change it.

Parameters

max_items

the max number of items that will be displayed at that level

See Also

action_menu_hierarchy_destroy
void action_menu_level_set_display_mode(ActionMenuLevel * level, ActionMenuLevelDisplayMode display_mode)

Set the action menu display mode.

Parameters

level

The ActionMenuLevel whose display mode you want to change

display_mode

The display mode for the action menu (3 vs. 1 item per row)

ActionMenuItem * action_menu_level_add_action(ActionMenuLevel * level, const char * label, ActionMenuPerformActionCb cb, void * action_data)

Add an action to an ActionLevel.

Parameters

level

the level to add the action to

label

the text to display for the action in the menu

cb

the callback that will be triggered when this action is actuated

action_data

data to pass to the callback for this action

Returns

a reference to the new ActionMenuItem on success, NULL if the level is full

ActionMenuItem * action_menu_level_add_child(ActionMenuLevel * level, ActionMenuLevel * child, const char * label)

Add a child to this ActionMenuLevel.

Parameters

level

the parent level

child

the child level

label

the text to display in the action menu for this level

Returns

a reference to the new ActionMenuItem on success, NULL if the level is full

void action_menu_hierarchy_destroy(const ActionMenuLevel * root, ActionMenuEachItemCb each_cb, void * context)

Destroy a hierarchy of ActionMenuLevels.

Note

Typical implementations will cleanup memory allocated for the item label/data associated with each item in the callback

Hierarchy is traversed in post-order. In other words, all children items are freed before their parent is freed.

Parameters

root

the root level in the hierarchy

each_cb

a callback to call on every ActionMenuItem in every level

context

a context pointer to pass to each_cb on invocation

void * action_menu_get_context(ActionMenu * action_menu)

Get the context pointer this ActionMenu was created with.

Parameters

action_menu

A pointer to an ActionMenu

Returns

the context pointer initially provided in the ActionMenuConfig. NULL if none exists.

ActionMenuLevel * action_menu_get_root_level(ActionMenu * action_menu)

Get the root level of an ActionMenu.

Parameters

action_menu

the ActionMenu you want to know about

Returns

a pointer to the root ActionMenuLevel for the given ActionMenu, NULL if invalid

ActionMenu * action_menu_open(ActionMenuConfig * config)

Open a new ActionMenu. The ActionMenu acts much like a window. It fills the whole screen and handles clicks.

Parameters

config

the configuration info for this new ActionMenu

Returns

the new ActionMenu

void action_menu_freeze(ActionMenu * action_menu)

Freeze the ActionMenu. The ActionMenu will no longer respond to user input.

Note

this API should be used when waiting for asynchronous operation.

Parameters

action_menu

the ActionMenu

void action_menu_unfreeze(ActionMenu * action_menu)

Unfreeze the ActionMenu previously frozen with action_menu_freeze.

Parameters

action_menu

the ActionMenu to unfreeze

void action_menu_set_result_window(ActionMenu * action_menu, Window * result_window)

Set the result window for an ActionMenu. The result window will be shown when the ActionMenu closes.

Note

repeated call will result in only the last call to be applied, i.e. only one result window is ever set

Parameters

action_menu

the ActionMenu

result_window

the window to insert, pass NULL to remove the current result window

void action_menu_close(ActionMenu * action_menu, bool animated)

Close the ActionMenu, whether it is frozen or not.

Note

this API can be used on a frozen ActionMenu once the data required to build the result window has been received and the result window has been set

Parameters

action_menu

the ActionMenu to close

animated

whether or not show a close animation

Data Structure Documentation

struct ActionMenuConfig

Configuration struct for the ActionMenu.

Data Fields

const ActionMenuLevel * root_level

the root level of the ActionMenu

void * context

a context pointer which will be accessbile when actions are performed

struct ActionMenuConfig::@15 colors
ActionMenuDidCloseCb will_close

Called immediately before the ActionMenu closes.

ActionMenuDidCloseCb did_close

a callback used to cleanup memory after the menu has closed

ActionMenuAlign align

Enum Documentation

enum ActionMenuAlign

Enumerators

ActionMenuAlignTop
ActionMenuAlignCenter
enum ActionMenuLevelDisplayMode

enum value that controls whether menu items are displayed in a grid (similarly to the emoji replies) or in a single column (reminiscent of MenuLayer)

Enumerators

ActionMenuLevelDisplayModeWide

Each item gets its own row.

ActionMenuLevelDisplayModeThin

Grid view: multiple items per row.

Typedef Documentation

typedef struct ActionMenuItem ActionMenuItem
typedef struct ActionMenuLevel ActionMenuLevel
typedef struct ActionMenu ActionMenu
typedef void(* ActionMenuDidCloseCb)(ActionMenu *menu, const ActionMenuItem *performed_action, void *context)

Callback executed after the ActionMenu has closed, so memory may be freed.

Parameters

root_level

the root level passed to the ActionMenu

performed_action

the ActionMenuItem for the action that was performed, NULL if the ActionMenu is closing without an action being selected by the user

context

the context passed to the ActionMenu

typedef void(* ActionMenuPerformActionCb)(ActionMenu *action_menu, const ActionMenuItem *action, void *context)

Callback executed when a given action is selected.

Note

the action menu is closed immediately after an action is performed, unless it is frozen in the ActionMenuPerformActionCb

Parameters

action_menu

the action menu currently on screen

action

the action that was triggered

context

the context passed to the action menu

typedef void(* ActionMenuEachItemCb)(const ActionMenuItem *item, void *context)

Callback invoked for each item in an action menu hierarchy.

Parameters

item

the current action menu item

a

caller-provided context callback

Need some help?

Functions

  • action_menu_item_get_label
  • action_menu_item_get_action_data
  • action_menu_level_create
  • action_menu_level_set_display_mode
  • action_menu_level_add_action
  • action_menu_level_add_child
  • action_menu_hierarchy_destroy
  • action_menu_get_context
  • action_menu_get_root_level
  • action_menu_open
  • action_menu_freeze
  • action_menu_unfreeze
  • action_menu_set_result_window
  • action_menu_close

Data Structures

  • ActionMenuConfig

Enums

  • ActionMenuAlign
  • ActionMenuLevelDisplayMode

Typedefs

  • ActionMenuItem
  • ActionMenuLevel
  • ActionMenu
  • ActionMenuDidCloseCb
  • ActionMenuPerformActionCb
  • ActionMenuEachItemCb

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can send us a message through the website!