Events

Application events.

Types

oc_event_type

typedef enum oc_event_type
{
    OC_EVENT_NONE = 0,
    OC_EVENT_KEYBOARD_MODS = 1,
    OC_EVENT_KEYBOARD_KEY = 2,
    OC_EVENT_KEYBOARD_CHAR = 3,
    OC_EVENT_MOUSE_BUTTON = 4,
    OC_EVENT_MOUSE_MOVE = 5,
    OC_EVENT_MOUSE_WHEEL = 6,
    OC_EVENT_MOUSE_ENTER = 7,
    OC_EVENT_MOUSE_LEAVE = 8,
    OC_EVENT_CLIPBOARD_PASTE = 9,
    OC_EVENT_WINDOW_RESIZE = 10,
    OC_EVENT_WINDOW_MOVE = 11,
    OC_EVENT_WINDOW_FOCUS = 12,
    OC_EVENT_WINDOW_UNFOCUS = 13,
    OC_EVENT_WINDOW_HIDE = 14,
    OC_EVENT_WINDOW_SHOW = 15,
    OC_EVENT_WINDOW_CLOSE = 16,
    OC_EVENT_PATHDROP = 17,
    OC_EVENT_FRAME = 18,
    OC_EVENT_QUIT = 19
} oc_event_type;

This enum defines the type events that can be sent to the application by the runtime. This determines which member of the oc_event union field is active.

Enum Constants

  • OC_EVENT_NONE No event. That could be used simply to wake up the application.
  • OC_EVENT_KEYBOARD_MODS A modifier key event. This event is sent when a key such as Alt, Control, Command or Shift are pressed, released, or repeated. The key field contains the event's details.
  • OC_EVENT_KEYBOARD_KEY A key event. This event is sent when a normal key is pressed, released, or repeated. The key field contains the event's details.
  • OC_EVENT_KEYBOARD_CHAR A character input event. This event is sent when an input character is produced by the keyboard. The character field contains the event's details.
  • OC_EVENT_MOUSE_BUTTON A mouse button event. This is event sent when one of the mouse buttons is pressed, released, or clicked. The key field contains the event's details.
  • OC_EVENT_MOUSE_MOVE A mouse move event. This is event sent when the mouse is moved. The mouse field contains the event's details.
  • OC_EVENT_MOUSE_WHEEL A mouse wheel event. This is event sent when the mouse wheel is moved (or when a trackpad is scrolled). The mouse field contains the event's details.
  • OC_EVENT_MOUSE_ENTER A mouse enter event. This event is sent when the mouse enters the application's window. The mouse field contains the event's details.
  • OC_EVENT_MOUSE_LEAVE A mouse leave event. This event is sent when the mouse leaves the application's window.
  • OC_EVENT_CLIPBOARD_PASTE A clipboard paste event. This event is sent when the user uses the paste shortcut while the application window has focus.
  • OC_EVENT_WINDOW_RESIZE A resize event. This event is sent when the application's window is resized. The move field contains the event's details.
  • OC_EVENT_WINDOW_MOVE A move event. This event is sent when the window is moved. The move field contains the event's details.
  • OC_EVENT_WINDOW_FOCUS A focus event. This event is sent when the application gains focus.
  • OC_EVENT_WINDOW_UNFOCUS An unfocus event. This event is sent when the application looses focus.
  • OC_EVENT_WINDOW_HIDE A hide event. This event is sent when the application's window is hidden or minimized.
  • OC_EVENT_WINDOW_SHOW A show event. This event is sent when the application's window is shown or de-minimized.
  • OC_EVENT_WINDOW_CLOSE A close event. This event is sent when the window is about to be closed.
  • OC_EVENT_PATHDROP A path drop event. This event is sent when the user drops files onto the application's window. The paths field contains the event's details.
  • OC_EVENT_FRAME A frame event. This event is sent when the application should render a frame.
  • OC_EVENT_QUIT A quit event. This event is sent when the application has been requested to quit.

oc_key_action

typedef enum oc_key_action
{
    OC_KEY_NO_ACTION = 0,
    OC_KEY_PRESS = 1,
    OC_KEY_RELEASE = 2,
    OC_KEY_REPEAT = 3
} oc_key_action;

This enum describes the actions that can happen to a key.

Enum Constants

  • OC_KEY_NO_ACTION No action happened on that key.
  • OC_KEY_PRESS The key was pressed.
  • OC_KEY_RELEASE The key was released.
  • OC_KEY_REPEAT The key was maintained pressed at least for the system's key repeat period.

oc_scan_code

typedef enum oc_scan_code
{
    OC_SCANCODE_UNKNOWN = 0,
    OC_SCANCODE_SPACE = 32,
    OC_SCANCODE_APOSTROPHE = 39,
    OC_SCANCODE_COMMA = 44,
    OC_SCANCODE_MINUS = 45,
    OC_SCANCODE_PERIOD = 46,
    OC_SCANCODE_SLASH = 47,
    OC_SCANCODE_0 = 48,
    OC_SCANCODE_1 = 49,
    OC_SCANCODE_2 = 50,
    OC_SCANCODE_3 = 51,
    OC_SCANCODE_4 = 52,
    OC_SCANCODE_5 = 53,
    OC_SCANCODE_6 = 54,
    OC_SCANCODE_7 = 55,
    OC_SCANCODE_8 = 56,
    OC_SCANCODE_9 = 57,
    OC_SCANCODE_SEMICOLON = 59,
    OC_SCANCODE_EQUAL = 61,
    OC_SCANCODE_LEFT_BRACKET = 91,
    OC_SCANCODE_BACKSLASH = 92,
    OC_SCANCODE_RIGHT_BRACKET = 93,
    OC_SCANCODE_GRAVE_ACCENT = 96,
    OC_SCANCODE_A = 97,
    OC_SCANCODE_B = 98,
    OC_SCANCODE_C = 99,
    OC_SCANCODE_D = 100,
    OC_SCANCODE_E = 101,
    OC_SCANCODE_F = 102,
    OC_SCANCODE_G = 103,
    OC_SCANCODE_H = 104,
    OC_SCANCODE_I = 105,
    OC_SCANCODE_J = 106,
    OC_SCANCODE_K = 107,
    OC_SCANCODE_L = 108,
    OC_SCANCODE_M = 109,
    OC_SCANCODE_N = 110,
    OC_SCANCODE_O = 111,
    OC_SCANCODE_P = 112,
    OC_SCANCODE_Q = 113,
    OC_SCANCODE_R = 114,
    OC_SCANCODE_S = 115,
    OC_SCANCODE_T = 116,
    OC_SCANCODE_U = 117,
    OC_SCANCODE_V = 118,
    OC_SCANCODE_W = 119,
    OC_SCANCODE_X = 120,
    OC_SCANCODE_Y = 121,
    OC_SCANCODE_Z = 122,
    OC_SCANCODE_WORLD_1 = 161,
    OC_SCANCODE_WORLD_2 = 162,
    OC_SCANCODE_ESCAPE = 256,
    OC_SCANCODE_ENTER = 257,
    OC_SCANCODE_TAB = 258,
    OC_SCANCODE_BACKSPACE = 259,
    OC_SCANCODE_INSERT = 260,
    OC_SCANCODE_DELETE = 261,
    OC_SCANCODE_RIGHT = 262,
    OC_SCANCODE_LEFT = 263,
    OC_SCANCODE_DOWN = 264,
    OC_SCANCODE_UP = 265,
    OC_SCANCODE_PAGE_UP = 266,
    OC_SCANCODE_PAGE_DOWN = 267,
    OC_SCANCODE_HOME = 268,
    OC_SCANCODE_END = 269,
    OC_SCANCODE_CAPS_LOCK = 280,
    OC_SCANCODE_SCROLL_LOCK = 281,
    OC_SCANCODE_NUM_LOCK = 282,
    OC_SCANCODE_PRINT_SCREEN = 283,
    OC_SCANCODE_PAUSE = 284,
    OC_SCANCODE_F1 = 290,
    OC_SCANCODE_F2 = 291,
    OC_SCANCODE_F3 = 292,
    OC_SCANCODE_F4 = 293,
    OC_SCANCODE_F5 = 294,
    OC_SCANCODE_F6 = 295,
    OC_SCANCODE_F7 = 296,
    OC_SCANCODE_F8 = 297,
    OC_SCANCODE_F9 = 298,
    OC_SCANCODE_F10 = 299,
    OC_SCANCODE_F11 = 300,
    OC_SCANCODE_F12 = 301,
    OC_SCANCODE_F13 = 302,
    OC_SCANCODE_F14 = 303,
    OC_SCANCODE_F15 = 304,
    OC_SCANCODE_F16 = 305,
    OC_SCANCODE_F17 = 306,
    OC_SCANCODE_F18 = 307,
    OC_SCANCODE_F19 = 308,
    OC_SCANCODE_F20 = 309,
    OC_SCANCODE_F21 = 310,
    OC_SCANCODE_F22 = 311,
    OC_SCANCODE_F23 = 312,
    OC_SCANCODE_F24 = 313,
    OC_SCANCODE_F25 = 314,
    OC_SCANCODE_KP_0 = 320,
    OC_SCANCODE_KP_1 = 321,
    OC_SCANCODE_KP_2 = 322,
    OC_SCANCODE_KP_3 = 323,
    OC_SCANCODE_KP_4 = 324,
    OC_SCANCODE_KP_5 = 325,
    OC_SCANCODE_KP_6 = 326,
    OC_SCANCODE_KP_7 = 327,
    OC_SCANCODE_KP_8 = 328,
    OC_SCANCODE_KP_9 = 329,
    OC_SCANCODE_KP_DECIMAL = 330,
    OC_SCANCODE_KP_DIVIDE = 331,
    OC_SCANCODE_KP_MULTIPLY = 332,
    OC_SCANCODE_KP_SUBTRACT = 333,
    OC_SCANCODE_KP_ADD = 334,
    OC_SCANCODE_KP_ENTER = 335,
    OC_SCANCODE_KP_EQUAL = 336,
    OC_SCANCODE_LEFT_SHIFT = 340,
    OC_SCANCODE_LEFT_CONTROL = 341,
    OC_SCANCODE_LEFT_ALT = 342,
    OC_SCANCODE_LEFT_SUPER = 343,
    OC_SCANCODE_RIGHT_SHIFT = 344,
    OC_SCANCODE_RIGHT_CONTROL = 345,
    OC_SCANCODE_RIGHT_ALT = 346,
    OC_SCANCODE_RIGHT_SUPER = 347,
    OC_SCANCODE_MENU = 348,
    OC_SCANCODE_COUNT = 349
} oc_scan_code;

A code representing a key's physical location. This is independent of the system's keyboard layout.

Enum Constants

  • OC_SCANCODE_UNKNOWN
  • OC_SCANCODE_SPACE
  • OC_SCANCODE_APOSTROPHE
  • OC_SCANCODE_COMMA
  • OC_SCANCODE_MINUS
  • OC_SCANCODE_PERIOD
  • OC_SCANCODE_SLASH
  • OC_SCANCODE_0
  • OC_SCANCODE_1
  • OC_SCANCODE_2
  • OC_SCANCODE_3
  • OC_SCANCODE_4
  • OC_SCANCODE_5
  • OC_SCANCODE_6
  • OC_SCANCODE_7
  • OC_SCANCODE_8
  • OC_SCANCODE_9
  • OC_SCANCODE_SEMICOLON
  • OC_SCANCODE_EQUAL
  • OC_SCANCODE_LEFT_BRACKET
  • OC_SCANCODE_BACKSLASH
  • OC_SCANCODE_RIGHT_BRACKET
  • OC_SCANCODE_GRAVE_ACCENT
  • OC_SCANCODE_A
  • OC_SCANCODE_B
  • OC_SCANCODE_C
  • OC_SCANCODE_D
  • OC_SCANCODE_E
  • OC_SCANCODE_F
  • OC_SCANCODE_G
  • OC_SCANCODE_H
  • OC_SCANCODE_I
  • OC_SCANCODE_J
  • OC_SCANCODE_K
  • OC_SCANCODE_L
  • OC_SCANCODE_M
  • OC_SCANCODE_N
  • OC_SCANCODE_O
  • OC_SCANCODE_P
  • OC_SCANCODE_Q
  • OC_SCANCODE_R
  • OC_SCANCODE_S
  • OC_SCANCODE_T
  • OC_SCANCODE_U
  • OC_SCANCODE_V
  • OC_SCANCODE_W
  • OC_SCANCODE_X
  • OC_SCANCODE_Y
  • OC_SCANCODE_Z
  • OC_SCANCODE_WORLD_1
  • OC_SCANCODE_WORLD_2
  • OC_SCANCODE_ESCAPE
  • OC_SCANCODE_ENTER
  • OC_SCANCODE_TAB
  • OC_SCANCODE_BACKSPACE
  • OC_SCANCODE_INSERT
  • OC_SCANCODE_DELETE
  • OC_SCANCODE_RIGHT
  • OC_SCANCODE_LEFT
  • OC_SCANCODE_DOWN
  • OC_SCANCODE_UP
  • OC_SCANCODE_PAGE_UP
  • OC_SCANCODE_PAGE_DOWN
  • OC_SCANCODE_HOME
  • OC_SCANCODE_END
  • OC_SCANCODE_CAPS_LOCK
  • OC_SCANCODE_SCROLL_LOCK
  • OC_SCANCODE_NUM_LOCK
  • OC_SCANCODE_PRINT_SCREEN
  • OC_SCANCODE_PAUSE
  • OC_SCANCODE_F1
  • OC_SCANCODE_F2
  • OC_SCANCODE_F3
  • OC_SCANCODE_F4
  • OC_SCANCODE_F5
  • OC_SCANCODE_F6
  • OC_SCANCODE_F7
  • OC_SCANCODE_F8
  • OC_SCANCODE_F9
  • OC_SCANCODE_F10
  • OC_SCANCODE_F11
  • OC_SCANCODE_F12
  • OC_SCANCODE_F13
  • OC_SCANCODE_F14
  • OC_SCANCODE_F15
  • OC_SCANCODE_F16
  • OC_SCANCODE_F17
  • OC_SCANCODE_F18
  • OC_SCANCODE_F19
  • OC_SCANCODE_F20
  • OC_SCANCODE_F21
  • OC_SCANCODE_F22
  • OC_SCANCODE_F23
  • OC_SCANCODE_F24
  • OC_SCANCODE_F25
  • OC_SCANCODE_KP_0
  • OC_SCANCODE_KP_1
  • OC_SCANCODE_KP_2
  • OC_SCANCODE_KP_3
  • OC_SCANCODE_KP_4
  • OC_SCANCODE_KP_5
  • OC_SCANCODE_KP_6
  • OC_SCANCODE_KP_7
  • OC_SCANCODE_KP_8
  • OC_SCANCODE_KP_9
  • OC_SCANCODE_KP_DECIMAL
  • OC_SCANCODE_KP_DIVIDE
  • OC_SCANCODE_KP_MULTIPLY
  • OC_SCANCODE_KP_SUBTRACT
  • OC_SCANCODE_KP_ADD
  • OC_SCANCODE_KP_ENTER
  • OC_SCANCODE_KP_EQUAL
  • OC_SCANCODE_LEFT_SHIFT
  • OC_SCANCODE_LEFT_CONTROL
  • OC_SCANCODE_LEFT_ALT
  • OC_SCANCODE_LEFT_SUPER
  • OC_SCANCODE_RIGHT_SHIFT
  • OC_SCANCODE_RIGHT_CONTROL
  • OC_SCANCODE_RIGHT_ALT
  • OC_SCANCODE_RIGHT_SUPER
  • OC_SCANCODE_MENU
  • OC_SCANCODE_COUNT

oc_key_code

typedef enum oc_key_code
{
    OC_KEY_UNKNOWN = 0,
    OC_KEY_SPACE = 32,
    OC_KEY_APOSTROPHE = 39,
    OC_KEY_COMMA = 44,
    OC_KEY_MINUS = 45,
    OC_KEY_PERIOD = 46,
    OC_KEY_SLASH = 47,
    OC_KEY_0 = 48,
    OC_KEY_1 = 49,
    OC_KEY_2 = 50,
    OC_KEY_3 = 51,
    OC_KEY_4 = 52,
    OC_KEY_5 = 53,
    OC_KEY_6 = 54,
    OC_KEY_7 = 55,
    OC_KEY_8 = 56,
    OC_KEY_9 = 57,
    OC_KEY_SEMICOLON = 59,
    OC_KEY_EQUAL = 61,
    OC_KEY_LEFT_BRACKET = 91,
    OC_KEY_BACKSLASH = 92,
    OC_KEY_RIGHT_BRACKET = 93,
    OC_KEY_GRAVE_ACCENT = 96,
    OC_KEY_A = 97,
    OC_KEY_B = 98,
    OC_KEY_C = 99,
    OC_KEY_D = 100,
    OC_KEY_E = 101,
    OC_KEY_F = 102,
    OC_KEY_G = 103,
    OC_KEY_H = 104,
    OC_KEY_I = 105,
    OC_KEY_J = 106,
    OC_KEY_K = 107,
    OC_KEY_L = 108,
    OC_KEY_M = 109,
    OC_KEY_N = 110,
    OC_KEY_O = 111,
    OC_KEY_P = 112,
    OC_KEY_Q = 113,
    OC_KEY_R = 114,
    OC_KEY_S = 115,
    OC_KEY_T = 116,
    OC_KEY_U = 117,
    OC_KEY_V = 118,
    OC_KEY_W = 119,
    OC_KEY_X = 120,
    OC_KEY_Y = 121,
    OC_KEY_Z = 122,
    OC_KEY_WORLD_1 = 161,
    OC_KEY_WORLD_2 = 162,
    OC_KEY_ESCAPE = 256,
    OC_KEY_ENTER = 257,
    OC_KEY_TAB = 258,
    OC_KEY_BACKSPACE = 259,
    OC_KEY_INSERT = 260,
    OC_KEY_DELETE = 261,
    OC_KEY_RIGHT = 262,
    OC_KEY_LEFT = 263,
    OC_KEY_DOWN = 264,
    OC_KEY_UP = 265,
    OC_KEY_PAGE_UP = 266,
    OC_KEY_PAGE_DOWN = 267,
    OC_KEY_HOME = 268,
    OC_KEY_END = 269,
    OC_KEY_CAPS_LOCK = 280,
    OC_KEY_SCROLL_LOCK = 281,
    OC_KEY_NUM_LOCK = 282,
    OC_KEY_PRINT_SCREEN = 283,
    OC_KEY_PAUSE = 284,
    OC_KEY_F1 = 290,
    OC_KEY_F2 = 291,
    OC_KEY_F3 = 292,
    OC_KEY_F4 = 293,
    OC_KEY_F5 = 294,
    OC_KEY_F6 = 295,
    OC_KEY_F7 = 296,
    OC_KEY_F8 = 297,
    OC_KEY_F9 = 298,
    OC_KEY_F10 = 299,
    OC_KEY_F11 = 300,
    OC_KEY_F12 = 301,
    OC_KEY_F13 = 302,
    OC_KEY_F14 = 303,
    OC_KEY_F15 = 304,
    OC_KEY_F16 = 305,
    OC_KEY_F17 = 306,
    OC_KEY_F18 = 307,
    OC_KEY_F19 = 308,
    OC_KEY_F20 = 309,
    OC_KEY_F21 = 310,
    OC_KEY_F22 = 311,
    OC_KEY_F23 = 312,
    OC_KEY_F24 = 313,
    OC_KEY_F25 = 314,
    OC_KEY_KP_0 = 320,
    OC_KEY_KP_1 = 321,
    OC_KEY_KP_2 = 322,
    OC_KEY_KP_3 = 323,
    OC_KEY_KP_4 = 324,
    OC_KEY_KP_5 = 325,
    OC_KEY_KP_6 = 326,
    OC_KEY_KP_7 = 327,
    OC_KEY_KP_8 = 328,
    OC_KEY_KP_9 = 329,
    OC_KEY_KP_DECIMAL = 330,
    OC_KEY_KP_DIVIDE = 331,
    OC_KEY_KP_MULTIPLY = 332,
    OC_KEY_KP_SUBTRACT = 333,
    OC_KEY_KP_ADD = 334,
    OC_KEY_KP_ENTER = 335,
    OC_KEY_KP_EQUAL = 336,
    OC_KEY_LEFT_SHIFT = 340,
    OC_KEY_LEFT_CONTROL = 341,
    OC_KEY_LEFT_ALT = 342,
    OC_KEY_LEFT_SUPER = 343,
    OC_KEY_RIGHT_SHIFT = 344,
    OC_KEY_RIGHT_CONTROL = 345,
    OC_KEY_RIGHT_ALT = 346,
    OC_KEY_RIGHT_SUPER = 347,
    OC_KEY_MENU = 348,
    OC_KEY_COUNT = 349
} oc_key_code;

A code identifying a key. The physical location of the key corresponding to a given key code depends on the system's keyboard layout.

Enum Constants

  • OC_KEY_UNKNOWN
  • OC_KEY_SPACE
  • OC_KEY_APOSTROPHE
  • OC_KEY_COMMA
  • OC_KEY_MINUS
  • OC_KEY_PERIOD
  • OC_KEY_SLASH
  • OC_KEY_0
  • OC_KEY_1
  • OC_KEY_2
  • OC_KEY_3
  • OC_KEY_4
  • OC_KEY_5
  • OC_KEY_6
  • OC_KEY_7
  • OC_KEY_8
  • OC_KEY_9
  • OC_KEY_SEMICOLON
  • OC_KEY_EQUAL
  • OC_KEY_LEFT_BRACKET
  • OC_KEY_BACKSLASH
  • OC_KEY_RIGHT_BRACKET
  • OC_KEY_GRAVE_ACCENT
  • OC_KEY_A
  • OC_KEY_B
  • OC_KEY_C
  • OC_KEY_D
  • OC_KEY_E
  • OC_KEY_F
  • OC_KEY_G
  • OC_KEY_H
  • OC_KEY_I
  • OC_KEY_J
  • OC_KEY_K
  • OC_KEY_L
  • OC_KEY_M
  • OC_KEY_N
  • OC_KEY_O
  • OC_KEY_P
  • OC_KEY_Q
  • OC_KEY_R
  • OC_KEY_S
  • OC_KEY_T
  • OC_KEY_U
  • OC_KEY_V
  • OC_KEY_W
  • OC_KEY_X
  • OC_KEY_Y
  • OC_KEY_Z
  • OC_KEY_WORLD_1
  • OC_KEY_WORLD_2
  • OC_KEY_ESCAPE
  • OC_KEY_ENTER
  • OC_KEY_TAB
  • OC_KEY_BACKSPACE
  • OC_KEY_INSERT
  • OC_KEY_DELETE
  • OC_KEY_RIGHT
  • OC_KEY_LEFT
  • OC_KEY_DOWN
  • OC_KEY_UP
  • OC_KEY_PAGE_UP
  • OC_KEY_PAGE_DOWN
  • OC_KEY_HOME
  • OC_KEY_END
  • OC_KEY_CAPS_LOCK
  • OC_KEY_SCROLL_LOCK
  • OC_KEY_NUM_LOCK
  • OC_KEY_PRINT_SCREEN
  • OC_KEY_PAUSE
  • OC_KEY_F1
  • OC_KEY_F2
  • OC_KEY_F3
  • OC_KEY_F4
  • OC_KEY_F5
  • OC_KEY_F6
  • OC_KEY_F7
  • OC_KEY_F8
  • OC_KEY_F9
  • OC_KEY_F10
  • OC_KEY_F11
  • OC_KEY_F12
  • OC_KEY_F13
  • OC_KEY_F14
  • OC_KEY_F15
  • OC_KEY_F16
  • OC_KEY_F17
  • OC_KEY_F18
  • OC_KEY_F19
  • OC_KEY_F20
  • OC_KEY_F21
  • OC_KEY_F22
  • OC_KEY_F23
  • OC_KEY_F24
  • OC_KEY_F25
  • OC_KEY_KP_0
  • OC_KEY_KP_1
  • OC_KEY_KP_2
  • OC_KEY_KP_3
  • OC_KEY_KP_4
  • OC_KEY_KP_5
  • OC_KEY_KP_6
  • OC_KEY_KP_7
  • OC_KEY_KP_8
  • OC_KEY_KP_9
  • OC_KEY_KP_DECIMAL
  • OC_KEY_KP_DIVIDE
  • OC_KEY_KP_MULTIPLY
  • OC_KEY_KP_SUBTRACT
  • OC_KEY_KP_ADD
  • OC_KEY_KP_ENTER
  • OC_KEY_KP_EQUAL
  • OC_KEY_LEFT_SHIFT
  • OC_KEY_LEFT_CONTROL
  • OC_KEY_LEFT_ALT
  • OC_KEY_LEFT_SUPER
  • OC_KEY_RIGHT_SHIFT
  • OC_KEY_RIGHT_CONTROL
  • OC_KEY_RIGHT_ALT
  • OC_KEY_RIGHT_SUPER
  • OC_KEY_MENU
  • OC_KEY_COUNT

oc_keymod_flags

typedef enum oc_keymod_flags
{
    OC_KEYMOD_NONE = 0,
    OC_KEYMOD_ALT = 1,
    OC_KEYMOD_SHIFT = 2,
    OC_KEYMOD_CTRL = 4,
    OC_KEYMOD_CMD = 8,
    OC_KEYMOD_MAIN_MODIFIER = 16
} oc_keymod_flags;

Enum Constants

  • OC_KEYMOD_NONE
  • OC_KEYMOD_ALT
  • OC_KEYMOD_SHIFT
  • OC_KEYMOD_CTRL
  • OC_KEYMOD_CMD
  • OC_KEYMOD_MAIN_MODIFIER

oc_mouse_button

typedef enum oc_mouse_button
{
    OC_MOUSE_LEFT = 0,
    OC_MOUSE_RIGHT = 1,
    OC_MOUSE_MIDDLE = 2,
    OC_MOUSE_EXT1 = 3,
    OC_MOUSE_EXT2 = 4,
    OC_MOUSE_BUTTON_COUNT = 5
} oc_mouse_button;

A code identifying a mouse button.

Enum Constants

  • OC_MOUSE_LEFT
  • OC_MOUSE_RIGHT
  • OC_MOUSE_MIDDLE
  • OC_MOUSE_EXT1
  • OC_MOUSE_EXT2
  • OC_MOUSE_BUTTON_COUNT

oc_key_event

typedef struct oc_key_event
{
    oc_key_action action;
    oc_scan_code scanCode;
    oc_key_code keyCode;
    oc_mouse_button button;
    oc_keymod_flags mods;
    u8 clickCount;
} oc_key_event;

A structure describing a key event or a mouse button event.

Fields

  • action The action that was done on the key.
  • scanCode The scan code of the key. Only valid for key events.
  • keyCode The key code of the key. Only valid for key events.
  • button The button of the mouse. Only valid for mouse button events.
  • mods Modifier flags indicating which modifier keys where pressed at the time of the event.
  • clickCount The number of clicks that where detected for the button. Only valid for mouse button events.

oc_char_event

typedef struct oc_char_event
{
    oc_utf32 codepoint;
    char sequence[8];
    u8 seqLen;
} oc_char_event;

A structure describing a character input event.

Fields

  • codepoint The unicode codepoint of the character.
  • sequence The utf8 sequence of the character.
  • seqLen The utf8 sequence length.

oc_mouse_event

typedef struct oc_mouse_event
{
    f32 x;
    f32 y;
    f32 deltaX;
    f32 deltaY;
    oc_keymod_flags mods;
} oc_mouse_event;

A structure describing a mouse move or a mouse wheel event. Mouse coordinates have their origin at the top-left corner of the window, with the y axis going down.

Fields

  • x The x coordinate of the mouse.
  • y The y coordinate of the mouse.
  • deltaX The delta from the last x coordinate of the mouse, or the scroll value along the x coordinate.
  • deltaY The delta from the last y coordinate of the mouse, or the scoll value along the y coordinate.
  • mods Modifier flags indicating which modifier keys where pressed at the time of the event.

oc_move_event

typedef struct oc_move_event
{
    oc_rect frame;
    oc_rect content;
} oc_move_event;

A structure describing a window move or resize event.

Fields

  • frame The position and dimension of the frame rectangle, i.e. including the window title bar and border.
  • content The position and dimension of the content rectangle, relative to the frame rectangle.

oc_event

typedef struct oc_event
{
    oc_window window;
    oc_event_type type;
    union
    {
        oc_key_event key;
        oc_char_event character;
        oc_mouse_event mouse;
        oc_move_event move;
        oc_str8_list paths;
    };
} oc_event;

A structure describing an event sent to the application.

Fields

  • window The window in which this event happened.
  • type The type of the event. This determines which member of the event union is active.

oc_file_dialog_kind

typedef enum oc_file_dialog_kind
{
    OC_FILE_DIALOG_SAVE = 0,
    OC_FILE_DIALOG_OPEN = 1
} oc_file_dialog_kind;

This enum describes the kinds of possible file dialogs.

Enum Constants

  • OC_FILE_DIALOG_SAVE The file dialog is a save dialog.
  • OC_FILE_DIALOG_OPEN The file dialog is an open dialog.

oc_file_dialog_flags

typedef u32 oc_file_dialog_flags;

A type for flags describing various file dialog options.


_oc_file_dialog_flags

typedef enum _oc_file_dialog_flags
{
    OC_FILE_DIALOG_FILES = 1,
    OC_FILE_DIALOG_DIRECTORIES = 2,
    OC_FILE_DIALOG_MULTIPLE = 4,
    OC_FILE_DIALOG_CREATE_DIRECTORIES = 8
} _oc_file_dialog_flags;

File dialog flags.

Enum Constants

  • OC_FILE_DIALOG_FILES This dialog allows selecting files.
  • OC_FILE_DIALOG_DIRECTORIES This dialog allows selecting directories.
  • OC_FILE_DIALOG_MULTIPLE This dialog allows selecting multiple items.
  • OC_FILE_DIALOG_CREATE_DIRECTORIES This dialog allows creating directories.

oc_file_dialog_desc

typedef struct oc_file_dialog_desc
{
    oc_file_dialog_kind kind;
    oc_file_dialog_flags flags;
    oc_str8 title;
    oc_str8 okLabel;
    oc_file startAt;
    oc_str8 startPath;
    oc_str8_list filters;
} oc_file_dialog_desc;

A structure describing a file dialog.

Fields

  • kind The kind of file dialog, see oc_file_dialog_kind.
  • flags A combination of file dialog flags used to enable file dialog options.
  • title The title of the dialog, displayed in the dialog title bar.
  • okLabel Optional. The label of the OK button, e.g. "Save" or "Open".
  • startAt Optional. A file handle to the root directory for the dialog. If set to zero, the root directory is the application's default data directory.
  • startPath Optional. The path of the starting directory of the dialog, relative to its root directory. If set to nil, the dialog starts at its root directory.
  • filters A list of file extensions used to restrict which files can be selected in this dialog. An empty list allows all files to be selected. Extensions should be provided without a leading dot.

oc_file_dialog_button

typedef enum oc_file_dialog_button
{
    OC_FILE_DIALOG_CANCEL = 0,
    OC_FILE_DIALOG_OK = 1
} oc_file_dialog_button;

An enum identifying the button clicked by the user when a file dialog returns.

Enum Constants

  • OC_FILE_DIALOG_CANCEL The user clicked the "Cancel" button, or closed the dialog box.
  • OC_FILE_DIALOG_OK The user clicked the "OK" button.

oc_file_dialog_result

typedef struct oc_file_dialog_result
{
    oc_file_dialog_button button;
    oc_str8 path;
    oc_str8_list selection;
} oc_file_dialog_result;

A structure describing the result of a file dialog.

Fields

  • button The button clicked by the user.
  • path The path that was selected when the user clicked the OK button. If the dialog box had the OC_FILE_DIALOG_MULTIPLE flag set, this is the first file of the list of selected paths.
  • selection If the dialog box had the OC_FILE_DIALOG_MULTIPLE flag set and the user clicked the OK button, this list contains the selected paths.

Functions

oc_window_set_title

void oc_window_set_title(oc_str8 title);

Set the title of the application's window.

Parameters

  • title The title to display in the title bar of the application.

oc_window_set_size

void oc_window_set_size(oc_vec2 size);

Set the size of the application's window.

Parameters

  • size The new size of the application's window.

oc_request_quit

void oc_request_quit();

Request the system to quit the application.


oc_scancode_to_keycode

oc_key_code oc_scancode_to_keycode(oc_scan_code scanCode);

Convert a scancode to a keycode, according to current keyboard layout.

Parameters

  • scanCode The scan code to convert.

Return

The converted key code.


oc_clipboard_set_string

void oc_clipboard_set_string(oc_str8 string);

Put a string in the clipboard.

Parameters

  • string A string to put in the clipboard.