Flutter Engine
 
Loading...
Searching...
No Matches
FlutterKeyEvent Struct Reference

#include <embedder.h>

Public Attributes

size_t struct_size
 The size of this struct. Must be sizeof(FlutterKeyEvent).
 
double timestamp
 
FlutterKeyEventType type
 The event kind.
 
uint64_t physical
 
uint64_t logical
 
const char * character
 
bool synthesized
 
FlutterKeyEventDeviceType device_type
 The source device for the key event.
 

Detailed Description

A structure to represent a key event.

Sending FlutterKeyEvent via FlutterEngineSendKeyEvent results in a corresponding FlutterKeyEvent to be dispatched in the framework. It is embedder's responsibility to ensure the regularity of sent events, since the framework only performs simple one-to-one mapping. The events must conform the following rules:

  • Each key press sequence shall consist of one key down event (kind being kFlutterKeyEventTypeDown), zero or more repeat events, and one key up event, representing a physical key button being pressed, held, and released.
  • All events throughout a key press sequence shall have the same physical and logical. Having different characters is allowed.

A FlutterKeyEvent with physical 0 and logical 0 is an empty event. This is the only case either physical or logical can be 0. An empty event must be sent if a key message should be converted to no FlutterKeyEvents, for example, when a key down message is received for a key that has already been pressed according to the record. This is to ensure some FlutterKeyEvent arrives at the framework before raw key message. See https://github.com/flutter/flutter/issues/87230.

Definition at line 1382 of file embedder.h.

Member Data Documentation

◆ character

◆ device_type

FlutterKeyEventDeviceType FlutterKeyEvent::device_type

The source device for the key event.

Definition at line 1424 of file embedder.h.

Referenced by flutter::testing::ExpectKeyEventEq(), TEST(), and flutter::testing::TEST_F().

◆ logical

uint64_t FlutterKeyEvent::logical

◆ physical

uint64_t FlutterKeyEvent::physical

◆ struct_size

◆ synthesized

bool FlutterKeyEvent::synthesized

True if this event does not correspond to a native event.

The embedder is likely to skip events and/or construct new events that do not correspond to any native events in order to conform the regularity of events (as documented in FlutterKeyEvent). An example is when a key up is missed due to loss of window focus, on a platform that provides query to key pressing status, the embedder might realize that the key has been released at the next key event, and should construct a synthesized up event immediately before the actual event.

An event being synthesized means that the timestamp might greatly deviate from the actual time when the event occurs physically.

Definition at line 1422 of file embedder.h.

Referenced by flutter::testing::_EventEquals(), flutter::testing::ExpectKeyEventEq(), fl_key_embedder_responder_handle_event_impl(), synthesize_simple_event(), TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), and flutter::testing::TEST_F().

◆ timestamp

double FlutterKeyEvent::timestamp

The timestamp at which the key event was generated. The timestamp should be specified in microseconds and the clock should be the same as that used by FlutterEngineGetCurrentTime.

Definition at line 1388 of file embedder.h.

Referenced by flutter::testing::ExpectKeyEventEq(), fl_key_embedder_responder_handle_event_impl(), synthesize_simple_event(), TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ type


The documentation for this struct was generated from the following file: