mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
rework widget focus
This commit is contained in:
parent
e48ace3322
commit
a2cd516dde
1280
demos/assets.c
1280
demos/assets.c
File diff suppressed because it is too large
Load Diff
@ -1,63 +1,78 @@
|
||||
TK_CONST_DATA_ALIGN(const unsigned char ui_soft_keyboard[]) = {
|
||||
0x04,0x00,0x01,0x01,0xa6,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x6f,0x66,0x74,0x5f,0x6b,0x65,0x79,
|
||||
0x04,0x00,0x01,0x01,0xcb,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x6f,0x66,0x74,0x5f,0x6b,0x65,0x79,
|
||||
0x62,0x6f,0x61,0x72,0x64,0x00,0x64,0x61,0x74,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x12,0x12,0x22,0x11,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x65,0x78,0x74,
|
||||
0x00,0x43,0x75,0x73,0x74,0x6f,0x6d,0x20,0x53,0x6f,0x66,0x74,0x20,0x4b,0x65,0x79,0x62,0x6f,0x61,0x72,
|
||||
0x64,0x00,0x61,0x6e,0x69,0x6d,0x5f,0x68,0x69,0x6e,0x74,0x00,0x68,0x74,0x72,0x61,0x6e,0x73,0x6c,0x61,
|
||||
0x74,0x65,0x00,0x00,0x65,0x64,0x69,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x74,0x65,0x00,0x6d,0x6f,0x76,0x65,0x5f,0x66,0x6f,0x63,0x75,0x73,0x5f,0x75,0x70,0x5f,0x6b,0x65,0x79,
|
||||
0x00,0x75,0x70,0x00,0x6d,0x6f,0x76,0x65,0x5f,0x66,0x6f,0x63,0x75,0x73,0x5f,0x64,0x6f,0x77,0x6e,0x5f,
|
||||
0x6b,0x65,0x79,0x00,0x64,0x6f,0x77,0x6e,0x00,0x6d,0x6f,0x76,0x65,0x5f,0x66,0x6f,0x63,0x75,0x73,0x5f,
|
||||
0x6c,0x65,0x66,0x74,0x5f,0x6b,0x65,0x79,0x00,0x6c,0x65,0x66,0x74,0x00,0x6d,0x6f,0x76,0x65,0x5f,0x66,
|
||||
0x6f,0x63,0x75,0x73,0x5f,0x72,0x69,0x67,0x68,0x74,0x5f,0x6b,0x65,0x79,0x00,0x72,0x69,0x67,0x68,0x74,
|
||||
0x00,0x00,0x65,0x64,0x69,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,
|
||||
0x00,0x00,0x5a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x2c,0x79,0x3d,0x31,0x30,0x2c,0x77,
|
||||
0x3d,0x39,0x30,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x69,0x6e,0x70,0x75,0x74,0x5f,0x74,0x79,0x70,
|
||||
0x65,0x00,0x63,0x75,0x73,0x74,0x6f,0x6d,0x00,0x66,0x6f,0x63,0x75,0x73,0x65,0x64,0x00,0x74,0x72,0x75,
|
||||
0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x00,0x74,0x69,0x70,0x73,0x00,0x63,0x75,0x73,0x74,0x6f,0x6d,0x00,
|
||||
0x00,0x00,0x76,0x69,0x65,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,
|
||||
0x00,0x00,0x5a,0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x2c,0x79,0x3d,0x36,0x30,0x2c,0x77,
|
||||
0x3d,0x39,0x30,0x25,0x2c,0x68,0x3d,0x2d,0x36,0x30,0x29,0x00,0x69,0x73,0x5f,0x6b,0x65,0x79,0x62,0x6f,
|
||||
0x61,0x72,0x64,0x00,0x74,0x72,0x75,0x65,0x00,0x67,0x72,0x61,0x62,0x5f,0x6b,0x65,0x79,0x73,0x00,0x74,
|
||||
0x72,0x75,0x65,0x00,0x63,0x68,0x69,0x6c,0x64,0x72,0x65,0x6e,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,
|
||||
0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x72,0x3d,0x34,0x2c,0x63,0x3d,0x34,0x2c,0x6d,0x3d,0x35,0x2c,
|
||||
0x73,0x3d,0x35,0x29,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x0a,0x00,0x00,0x00,0x5a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x2c,0x79,0x3d,0x31,0x30,
|
||||
0x2c,0x77,0x3d,0x39,0x30,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x69,0x6e,0x70,0x75,0x74,0x5f,0x74,
|
||||
0x79,0x70,0x65,0x00,0x63,0x75,0x73,0x74,0x6f,0x6d,0x00,0x66,0x6f,0x63,0x75,0x73,0x65,0x64,0x00,0x74,
|
||||
0x72,0x75,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x00,0x74,0x69,0x70,0x73,0x00,0x63,0x75,0x73,0x74,0x6f,
|
||||
0x6d,0x00,0x00,0x00,0x76,0x69,0x65,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x6f,0x63,0x75,0x73,0x61,
|
||||
0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,
|
||||
0x78,0x74,0x00,0x30,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x3c,0x00,0x00,0x00,0x5a,0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x2c,0x79,0x3d,0x36,0x30,
|
||||
0x2c,0x77,0x3d,0x39,0x30,0x25,0x2c,0x68,0x3d,0x2d,0x36,0x30,0x29,0x00,0x69,0x73,0x5f,0x6b,0x65,0x79,
|
||||
0x62,0x6f,0x61,0x72,0x64,0x00,0x74,0x72,0x75,0x65,0x00,0x63,0x68,0x69,0x6c,0x64,0x72,0x65,0x6e,0x5f,
|
||||
0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x72,0x3d,0x34,0x2c,0x63,
|
||||
0x3d,0x34,0x2c,0x6d,0x3d,0x35,0x2c,0x73,0x3d,0x35,0x29,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x6f,0x63,0x75,0x73,
|
||||
0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,
|
||||
0x65,0x78,0x74,0x00,0x31,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x6f,0x63,0x75,
|
||||
0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,
|
||||
0x74,0x65,0x78,0x74,0x00,0x32,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x6f,0x63,
|
||||
0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,
|
||||
0x00,0x74,0x65,0x78,0x74,0x00,0x33,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x6f,
|
||||
0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,
|
||||
0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x34,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,
|
||||
0x6f,0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,
|
||||
0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x35,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x30,0x00,0x00,0x00,0x62,
|
||||
0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x66,0x6f,0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,0x00,
|
||||
0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x36,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,
|
||||
0x00,0x31,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,
|
||||
0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x32,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,
|
||||
0x00,0x66,0x6f,0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,0x65,
|
||||
0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x37,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,
|
||||
0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x33,0x00,0x00,0x00,0x62,0x75,0x74,
|
||||
0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x34,
|
||||
0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,
|
||||
0x74,0x65,0x78,0x74,0x00,0x35,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,
|
||||
0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x36,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,
|
||||
0x00,0x00,0x66,0x6f,0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,0x6d,
|
||||
0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x38,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,
|
||||
0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x37,0x00,0x00,
|
||||
0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x66,0x6f,0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,0x61,
|
||||
0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x39,0x00,0x00,0x00,0x62,0x75,0x74,0x74,
|
||||
0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,
|
||||
0x78,0x74,0x00,0x38,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x66,0x6f,0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x6e,
|
||||
0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x23,0x00,0x00,0x00,0x62,0x75,0x74,
|
||||
0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,
|
||||
0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x39,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x6e,0x61,0x6d,0x65,0x00,0x6b,0x65,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x23,0x00,0x00,0x00,0x62,
|
||||
0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x62,0x61,0x63,0x6b,0x73,0x70,0x61,0x63,
|
||||
0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x3c,0x3d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*1238*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x66,0x6f,0x63,0x75,0x73,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,
|
||||
0x6e,0x61,0x6d,0x65,0x00,0x62,0x61,0x63,0x6b,0x73,0x70,0x61,0x63,0x65,0x00,0x74,0x65,0x78,0x74,0x00,
|
||||
0x3c,0x3d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*1531*/
|
||||
|
Binary file not shown.
@ -1,20 +1,21 @@
|
||||
|
||||
<window text="Custom Soft Keyboard" anim_hint="htranslate" >
|
||||
<window text="Custom Soft Keyboard" anim_hint="htranslate"
|
||||
move_focus_up_key="up" move_focus_down_key="down" move_focus_left_key="left" move_focus_right_key="right">
|
||||
<edit x="c" y="10" w="90%" h="30" focused="true" input_type="custom" text="" tips="custom"/>
|
||||
|
||||
<view y="60" x="c" w="90%" h="-60" is_keyboard="true"
|
||||
<view y="60" x="c" w="90%" h="-60" is_keyboard="true" grab_keys="true"
|
||||
children_layout="default(r=4,c=4,m=5,s=5)" >
|
||||
<button name="key" text="0" />
|
||||
<button name="key" text="1" />
|
||||
<button name="key" text="2" />
|
||||
<button name="key" text="3" />
|
||||
<button name="key" text="4" />
|
||||
<button name="key" text="5" />
|
||||
<button name="key" text="6" />
|
||||
<button name="key" text="7" />
|
||||
<button name="key" text="8" />
|
||||
<button name="key" text="9" />
|
||||
<button name="key" text="#" />
|
||||
<button name="backspace" text="<=" />
|
||||
<button focusable="true" name="key" text="0" />
|
||||
<button focusable="true" name="key" text="1" />
|
||||
<button focusable="true" name="key" text="2" />
|
||||
<button focusable="true" name="key" text="3" />
|
||||
<button focusable="true" name="key" text="4" />
|
||||
<button focusable="true" name="key" text="5" />
|
||||
<button focusable="true" name="key" text="6" />
|
||||
<button focusable="true" name="key" text="7" />
|
||||
<button focusable="true" name="key" text="8" />
|
||||
<button focusable="true" name="key" text="9" />
|
||||
<button focusable="true" name="key" text="#" />
|
||||
<button focusable="true" name="backspace" text="<=" />
|
||||
</view>
|
||||
</window>
|
||||
|
@ -136,22 +136,7 @@ int WINAPI wWinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPWSTR lpcmdli
|
||||
str_set(&str, utf8_line);
|
||||
command_line_to_argv(str.str, argv, &argc);
|
||||
#if defined(WIN32)
|
||||
#if !defined(NDEBUG)
|
||||
{
|
||||
bool_t log = FALSE;
|
||||
int8_t last_arg = MAX_ARGV - 1;
|
||||
if (argc > last_arg) {
|
||||
if (atoi(argv[last_arg]) == 1) {
|
||||
log = TRUE;
|
||||
}
|
||||
}
|
||||
if (log) {
|
||||
AllocConsole();
|
||||
FILE* fp = NULL;
|
||||
freopen_s(&fp, "CONOUT$", "w+t", stdout);
|
||||
}
|
||||
}
|
||||
#endif /*NDEBUG*/
|
||||
TK_ENABLE_CONSOLE();
|
||||
#endif /*WIN32*/
|
||||
#else
|
||||
#include "tkc/mem.h"
|
||||
|
@ -10,13 +10,13 @@
|
||||
<button ... focusable="true"/>
|
||||
```
|
||||
|
||||
在 C 中,可以这样指定:
|
||||
在 C 代码中,可以这样指定:
|
||||
|
||||
```
|
||||
widget_get_prop_bool(widget, WIDGET_PROP_FOCUSABLE, TRUE);
|
||||
widget_set_prop_bool(widget, WIDGET_PROP_FOCUSABLE, TRUE);
|
||||
```
|
||||
|
||||
**注意**: 如果指定了 fucusable 属性为 true,请确保控件的 style 中定义了 focused 状态的数据,否则会因为 focused 状态没有 style 数据而无法显示。如:
|
||||
> 如果指定了 fucusable 属性为 true,请确保控件的 style 中定义了 focused 状态的数据,否则会因为 focused 状态没有 style 数据而无法显示。如:
|
||||
|
||||
```
|
||||
<style name="default" border_color="#a0a0a0" text_color="black">
|
||||
@ -28,23 +28,17 @@
|
||||
</style> <focused bg_color="#e0e0e0" />
|
||||
```
|
||||
|
||||
## 二、切换焦点的按键
|
||||
## 二、前后切换焦点的按键
|
||||
|
||||
### 1. 缺省的向前和向后移动焦点的键值。
|
||||
### 1. 缺省用 tab 键循环切换焦点。
|
||||
|
||||
```
|
||||
#ifndef TK_KEY_MOVE_FOCUS_NEXT
|
||||
#define TK_KEY_MOVE_FOCUS_NEXT TK_KEY_TAB
|
||||
#define TK_KEY_MOVE_FOCUS_NEXT "tab"
|
||||
#endif /*TK_KEY_MOVE_FOCUS_NEXT*/
|
||||
|
||||
#ifndef TK_KEY_MOVE_FOCUS_PREV
|
||||
#define TK_KEY_MOVE_FOCUS_PREV TK_KEY_UNKNOWN
|
||||
#endif /*TK_KEY_MOVE_FOCUS_PREV*/
|
||||
```
|
||||
|
||||
> 用户可以重定义以上的宏来自定义这两个键值。
|
||||
|
||||
### 2. 窗口可以为当前窗口指定的向前和向后移动焦点的键值。
|
||||
### 2. 可以为当前窗口指定的向前和向后移动焦点的键值。
|
||||
|
||||
* move\_focus\_prev\_key 指定向前移动焦点的键值。
|
||||
* move\_focus\_next\_key 指定向后移动焦点的键值。
|
||||
@ -54,10 +48,49 @@
|
||||
```
|
||||
|
||||
> 在这个例子中,方向键 up 移动到前一个焦点控件,方向键 down 移动到下一个焦点控件。
|
||||
>
|
||||
> 键名的定义请参考 [enums.c](https://github.com/zlgopen/awtk/blob/master/src/base/enums.c#L99)。
|
||||
|
||||
## 三、设置初始焦点
|
||||
## 三、上下左右切换焦点的按键
|
||||
|
||||
在一些特殊的硬件设备上,没有触摸屏,只有上、下、左、右、确定和取消六个键。
|
||||
|
||||
为了快速切换焦点,AWTK 支持通过左右键切换水平焦点,通过上下键切换垂直焦点。可以通过窗口的下列属性来设置:
|
||||
|
||||
* move\_focus\_up\_key 向上移动焦点的键。
|
||||
* move\_focus\_down\_key 向下移动焦点的键。
|
||||
* move\_focus\_left\_key 向左移动焦点的键。
|
||||
* move\_focus\_right\_key 向右移动焦点的键。
|
||||
|
||||
示例:
|
||||
|
||||
```
|
||||
<window text="Custom Soft Keyboard" anim_hint="htranslate"
|
||||
move_focus_up_key="up" move_focus_down_key="down" move_focus_left_key="left" move_focus_right_key="right">
|
||||
|
||||
<edit name="edit" x="c" y="10" w="90%" h="30" focused="true" input_type="custom" text="" tips="custom"/>
|
||||
<view y="60" x="c" w="90%" h="-60" is_keyboard="true" grab_keys="true"
|
||||
children_layout="default(r=4,c=4,m=5,s=5)" >
|
||||
<button focusable="true" name="key0" text="0" />
|
||||
<button focusable="true" name="key1" text="1" />
|
||||
<button focusable="true" name="key2" text="2" />
|
||||
<button focusable="true" name="key3" text="3" />
|
||||
<button focusable="true" name="key4" text="4" />
|
||||
<button focusable="true" name="key5" text="5" />
|
||||
<button focusable="true" name="key6" text="6" />
|
||||
<button focusable="true" name="key7" text="7" />
|
||||
<button focusable="true" name="key8" text="8" />
|
||||
<button focusable="true" name="key9" text="9" />
|
||||
<button focusable="true" name="key#" text="#" />
|
||||
<button focusable="true" name="backspace" text="<=" />
|
||||
</view>
|
||||
</window>
|
||||
```
|
||||
|
||||
> 在这个例子中,方向键 up 移动到上方的焦点控件,方向键 down 移动到下方的焦点控件。
|
||||
> 方向键 left 移动到左方的焦点控件,方向键 right 移动到右方的焦点控件。
|
||||
|
||||
> 软键盘本身不能得到焦点,为了收到按键消息,需要指定属性 grab_keys="true"。
|
||||
|
||||
## 四、设置初始焦点
|
||||
|
||||
可以指定控件的 focused 属性为 true 将控件设置为初始焦点控件。
|
||||
|
||||
@ -70,5 +103,11 @@
|
||||
在 C 中,可以这样指定:
|
||||
|
||||
```
|
||||
widget_get_prop_bool(widget, WIDGET_PROP_FOCUSED, TRUE);
|
||||
widget_set_prop_bool(widget, WIDGET_PROP_FOCUSED, TRUE);
|
||||
```
|
||||
|
||||
## 五、参考
|
||||
|
||||
* [键名的定义:https://github.com/zlgopen/awtk/blob/master/src/base/enums.c](https://github.com/zlgopen/awtk/blob/master/src/base/enums.c#L99)。
|
||||
|
||||
* [键值映射:https://github.com/zlgopen/awtk/blob/master/docs/map_key.md](https://github.com/zlgopen/awtk/blob/master/docs/map_key.md)
|
@ -279,13 +279,9 @@ typedef struct _widget_animator_t widget_animator_t;
|
||||
#endif /*WITH_VGCANVAS*/
|
||||
|
||||
#ifndef TK_KEY_MOVE_FOCUS_NEXT
|
||||
#define TK_KEY_MOVE_FOCUS_NEXT TK_KEY_TAB
|
||||
#define TK_KEY_MOVE_FOCUS_NEXT "tab"
|
||||
#endif /*TK_KEY_MOVE_FOCUS_NEXT*/
|
||||
|
||||
#ifndef TK_KEY_MOVE_FOCUS_PREV
|
||||
#define TK_KEY_MOVE_FOCUS_PREV TK_KEY_UNKNOWN
|
||||
#endif /*TK_KEY_MOVE_FOCUS_PREV*/
|
||||
|
||||
struct _locale_info_t;
|
||||
typedef struct _locale_info_t locale_info_t;
|
||||
|
||||
|
@ -47,6 +47,10 @@
|
||||
return (value); \
|
||||
}
|
||||
|
||||
ret_t widget_focus_up(widget_t* widget);
|
||||
ret_t widget_focus_down(widget_t* widget);
|
||||
ret_t widget_focus_left(widget_t* widget);
|
||||
ret_t widget_focus_right(widget_t* widget);
|
||||
static ret_t widget_do_destroy(widget_t* widget);
|
||||
static ret_t widget_destroy_sync(widget_t* widget);
|
||||
static ret_t widget_destroy_async(widget_t* widget);
|
||||
@ -55,6 +59,9 @@ static ret_t widget_destroy_in_idle(const idle_info_t* info);
|
||||
static ret_t widget_dispatch_blur_event(widget_t* widget);
|
||||
static ret_t widget_on_paint_done(widget_t* widget, canvas_t* c);
|
||||
|
||||
typedef widget_t* (*widget_find_wanted_focus_widget_t)(widget_t* widget, darray_t* all_focusable);
|
||||
static ret_t widget_move_focus(widget_t* widget, widget_find_wanted_focus_widget_t find);
|
||||
|
||||
ret_t widget_set_need_update_style(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
|
||||
|
||||
@ -1332,6 +1339,36 @@ static ret_t widget_exec(widget_t* widget, const char* str) {
|
||||
}
|
||||
}
|
||||
|
||||
static ret_t widget_on_grabbed_keys(void* ctx, event_t* e) {
|
||||
if (e->type == EVT_KEY_DOWN || e->type == EVT_KEY_UP) {
|
||||
ret_t ret = RET_OK;
|
||||
widget_t* widget = WIDGET(ctx);
|
||||
widget_t* win = widget_get_window(widget);
|
||||
widget_t* top_win = window_manager_get_top_window(win->parent);
|
||||
|
||||
if (win == top_win) {
|
||||
if (e->type == EVT_KEY_DOWN) {
|
||||
ret = widget_on_keydown(widget, (key_event_t*)e);
|
||||
} else {
|
||||
ret = widget_on_keyup(widget, (key_event_t*)e);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t widget_on_ungrab_keys(void* ctx, event_t* e) {
|
||||
widget_t* widget = WIDGET(ctx);
|
||||
widget_t* wm = widget_get_window_manager(widget);
|
||||
|
||||
widget_off_by_tag(wm, tk_pointer_to_int(widget));
|
||||
|
||||
return RET_REMOVE;
|
||||
}
|
||||
|
||||
ret_t widget_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
||||
ret_t ret = RET_OK;
|
||||
prop_change_event_t e;
|
||||
@ -1408,6 +1445,19 @@ ret_t widget_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
||||
if (widget->custom_props == NULL) {
|
||||
widget->custom_props = object_default_create();
|
||||
}
|
||||
|
||||
if (tk_str_eq(name, WIDGET_PROP_GRAB_KEYS)) {
|
||||
widget_t* wm = widget_get_window_manager(widget);
|
||||
|
||||
if (value_bool(v)) {
|
||||
widget_on(widget, EVT_DESTROY, widget_on_ungrab_keys, widget);
|
||||
widget_on_with_tag(wm, EVT_KEY_DOWN, widget_on_grabbed_keys, widget,
|
||||
tk_pointer_to_int(widget));
|
||||
widget_on_with_tag(wm, EVT_KEY_UP, widget_on_grabbed_keys, widget,
|
||||
tk_pointer_to_int(widget));
|
||||
}
|
||||
}
|
||||
|
||||
ret = object_set_prop(widget->custom_props, name, v);
|
||||
}
|
||||
}
|
||||
@ -1776,22 +1826,46 @@ bool_t widget_is_activate_key(widget_t* widget, key_event_t* e) {
|
||||
(widget->vt->return_key_to_activate && e->key == TK_KEY_RETURN);
|
||||
}
|
||||
|
||||
static bool_t widget_is_move_focus_prev_key(widget_t* widget, key_event_t* e) {
|
||||
int32_t key = TK_KEY_MOVE_FOCUS_PREV;
|
||||
static bool_t widget_match_key(widget_t* widget, const char* prop, uint32_t key) {
|
||||
const char* value = NULL;
|
||||
widget_t* win = widget_get_window(widget);
|
||||
return_value_if_fail(widget != NULL && win != NULL && e != NULL, FALSE);
|
||||
key = widget_get_prop_int(win, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, key);
|
||||
return_value_if_fail(widget != NULL && win != NULL, FALSE);
|
||||
|
||||
return e->key == key;
|
||||
value = widget_get_prop_str(win, prop, NULL);
|
||||
if (value != NULL) {
|
||||
const key_type_value_t* kv = keys_type_find_by_value(key);
|
||||
if (kv != NULL) {
|
||||
if (tk_str_ieq(value, kv->name)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool_t widget_is_move_focus_prev_key(widget_t* widget, key_event_t* e) {
|
||||
return widget_match_key(widget, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, e->key);
|
||||
}
|
||||
|
||||
static bool_t widget_is_move_focus_next_key(widget_t* widget, key_event_t* e) {
|
||||
int32_t key = TK_KEY_MOVE_FOCUS_NEXT;
|
||||
widget_t* win = widget_get_window(widget);
|
||||
return_value_if_fail(widget != NULL && win != NULL && e != NULL, FALSE);
|
||||
key = widget_get_prop_int(win, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, key);
|
||||
return widget_match_key(widget, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, e->key);
|
||||
}
|
||||
|
||||
return e->key == key;
|
||||
static bool_t widget_is_move_focus_up_key(widget_t* widget, key_event_t* e) {
|
||||
return widget_match_key(widget, WIDGET_PROP_MOVE_FOCUS_UP_KEY, e->key);
|
||||
}
|
||||
|
||||
static bool_t widget_is_move_focus_down_key(widget_t* widget, key_event_t* e) {
|
||||
return widget_match_key(widget, WIDGET_PROP_MOVE_FOCUS_DOWN_KEY, e->key);
|
||||
}
|
||||
|
||||
static bool_t widget_is_move_focus_left_key(widget_t* widget, key_event_t* e) {
|
||||
return widget_match_key(widget, WIDGET_PROP_MOVE_FOCUS_LEFT_KEY, e->key);
|
||||
}
|
||||
|
||||
static bool_t widget_is_move_focus_right_key(widget_t* widget, key_event_t* e) {
|
||||
return widget_match_key(widget, WIDGET_PROP_MOVE_FOCUS_RIGHT_KEY, e->key);
|
||||
}
|
||||
|
||||
static ret_t widget_on_keydown_general(widget_t* widget, key_event_t* e) {
|
||||
@ -1816,6 +1890,26 @@ static ret_t widget_on_keydown_general(widget_t* widget, key_event_t* e) {
|
||||
ret = RET_STOP;
|
||||
widget_focus_first(widget);
|
||||
}
|
||||
} else if (widget_is_move_focus_up_key(widget, e)) {
|
||||
if (widget_is_focusable(widget)) {
|
||||
ret = RET_STOP;
|
||||
widget_focus_up(widget);
|
||||
}
|
||||
} else if (widget_is_move_focus_down_key(widget, e)) {
|
||||
if (widget_is_focusable(widget)) {
|
||||
ret = RET_STOP;
|
||||
widget_focus_down(widget);
|
||||
}
|
||||
} else if (widget_is_move_focus_left_key(widget, e)) {
|
||||
if (widget_is_focusable(widget)) {
|
||||
ret = RET_STOP;
|
||||
widget_focus_left(widget);
|
||||
}
|
||||
} else if (widget_is_move_focus_right_key(widget, e)) {
|
||||
if (widget_is_focusable(widget)) {
|
||||
ret = RET_STOP;
|
||||
widget_focus_right(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1888,6 +1982,7 @@ static ret_t widget_on_keyup_after_children(widget_t* widget, key_event_t* e) {
|
||||
}
|
||||
|
||||
static ret_t widget_on_keyup_impl(widget_t* widget, key_event_t* e) {
|
||||
ret_t ret = RET_OK;
|
||||
return_value_if_fail(widget != NULL && e != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(widget->vt != NULL, RET_BAD_PARAMS);
|
||||
|
||||
@ -1903,9 +1998,11 @@ static ret_t widget_on_keyup_impl(widget_t* widget, key_event_t* e) {
|
||||
widget_set_state(widget, WIDGET_STATE_NORMAL);
|
||||
}
|
||||
widget_dispatch(widget, pointer_event_init(&click, EVT_CLICK, widget, 0, 0));
|
||||
|
||||
ret = RET_STOP;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_t widget_on_keyup(widget_t* widget, key_event_t* e) {
|
||||
@ -2317,6 +2414,20 @@ widget_t* widget_get_window(widget_t* widget) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static widget_t* widget_get_window_or_keyboard(widget_t* widget) {
|
||||
widget_t* iter = widget;
|
||||
return_value_if_fail(widget != NULL, NULL);
|
||||
|
||||
while (iter) {
|
||||
if (widget_is_window(iter) || widget_is_keyboard(iter)) {
|
||||
return iter;
|
||||
}
|
||||
iter = iter->parent;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
widget_t* widget_get_window_manager(widget_t* widget) {
|
||||
widget_t* iter = widget;
|
||||
return_value_if_fail(widget != NULL, NULL);
|
||||
@ -3087,7 +3198,7 @@ static ret_t widget_on_visit_focusable(void* ctx, const void* data) {
|
||||
}
|
||||
|
||||
static ret_t widget_get_all_focusable_widgets_in_window(widget_t* widget, darray_t* all_focusable) {
|
||||
widget_t* win = widget_get_window(widget);
|
||||
widget_t* win = widget_get_window_or_keyboard(widget);
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, widget_on_visit_focusable, all_focusable);
|
||||
@ -3138,52 +3249,232 @@ ret_t widget_focus_first(widget_t* widget) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t widget_move_focus(widget_t* widget, bool_t next) {
|
||||
static widget_t* widget_find_prev_focus_widget(widget_t* widget, darray_t* all_focusable) {
|
||||
uint32_t i = 0;
|
||||
uint32_t focus = 0;
|
||||
darray_t all_focusable;
|
||||
return_value_if_fail(widget != NULL && widget->focused, RET_BAD_PARAMS);
|
||||
return_value_if_fail(darray_init(&all_focusable, 10, NULL, NULL) != NULL, RET_OOM);
|
||||
for (i = 0; i < all_focusable->size; i++) {
|
||||
widget_t* iter = WIDGET(all_focusable->elms[i]);
|
||||
|
||||
widget_get_all_focusable_widgets_in_window(widget, &all_focusable);
|
||||
if (iter == widget) {
|
||||
uint32_t focus = (i == 0) ? (all_focusable->size - 1) : (i - 1);
|
||||
|
||||
if (all_focusable.size > 1) {
|
||||
for (i = 0; i < all_focusable.size; i++) {
|
||||
widget_t* iter = WIDGET(all_focusable.elms[i]);
|
||||
if (iter == widget) {
|
||||
if (next) {
|
||||
if ((i + 1) == all_focusable.size) {
|
||||
focus = 0;
|
||||
} else {
|
||||
focus = i + 1;
|
||||
}
|
||||
} else {
|
||||
if (i == 0) {
|
||||
focus = all_focusable.size - 1;
|
||||
} else {
|
||||
focus = i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
iter = WIDGET(all_focusable.elms[focus]);
|
||||
widget_set_prop_bool(widget, WIDGET_PROP_FOCUSED, FALSE);
|
||||
widget_set_prop_bool(iter, WIDGET_PROP_FOCUSED, TRUE);
|
||||
break;
|
||||
}
|
||||
return WIDGET(all_focusable->elms[focus]);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static widget_t* widget_find_next_focus_widget(widget_t* widget, darray_t* all_focusable) {
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < all_focusable->size; i++) {
|
||||
widget_t* iter = WIDGET(all_focusable->elms[i]);
|
||||
|
||||
if (iter == widget) {
|
||||
uint32_t focus = ((i + 1) == all_focusable->size) ? (0) : (i + 1);
|
||||
|
||||
return WIDGET(all_focusable->elms[focus]);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool_t is_same_row(const rect_t* r1, const rect_t* r2) {
|
||||
int32_t cy = r2->y + r2->h / 2;
|
||||
|
||||
return (cy >= r1->y && cy < (r1->y + r1->h));
|
||||
}
|
||||
|
||||
static bool_t is_same_col(const rect_t* r1, const rect_t* r2) {
|
||||
int32_t cx = r2->x + r2->w / 2;
|
||||
|
||||
return (cx >= r1->x && cx < (r1->x + r1->w));
|
||||
}
|
||||
|
||||
static uint32_t distance2(const rect_t* r1, const rect_t* r2) {
|
||||
uint32_t dx = (r1->x + r1->w / 2) - (r2->x + r2->w / 2);
|
||||
uint32_t dy = (r1->y + r1->h / 2) - (r2->y + r2->h / 2);
|
||||
|
||||
return dx * dx + dy * dy;
|
||||
}
|
||||
|
||||
static bool_t match_up(const rect_t* widget, const rect_t* last_matched, const rect_t* iter) {
|
||||
if ((iter->y + iter->h / 2) > widget->y) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (last_matched == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (is_same_col(widget, iter)) {
|
||||
if (!is_same_col(widget, last_matched)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return (iter->y + iter->h) > (last_matched->y + last_matched->h);
|
||||
}
|
||||
} else {
|
||||
return distance2(widget, iter) < distance2(widget, last_matched);
|
||||
}
|
||||
}
|
||||
|
||||
static bool_t match_down(const rect_t* widget, const rect_t* last_matched, const rect_t* iter) {
|
||||
if ((iter->y + iter->h / 2) < (widget->y + widget->h)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (last_matched == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (is_same_row(widget, iter)) {
|
||||
if (!is_same_row(widget, last_matched)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return iter->y < last_matched->y;
|
||||
}
|
||||
} else {
|
||||
return distance2(widget, iter) < distance2(widget, last_matched);
|
||||
}
|
||||
}
|
||||
|
||||
static bool_t match_left(const rect_t* widget, const rect_t* last_matched, const rect_t* iter) {
|
||||
if ((iter->x + iter->w / 2) > widget->x) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (last_matched == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (is_same_row(widget, iter)) {
|
||||
if (!is_same_row(widget, last_matched)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return (iter->x + iter->w) > (last_matched->x + last_matched->w);
|
||||
}
|
||||
} else {
|
||||
return distance2(widget, iter) < distance2(widget, last_matched);
|
||||
}
|
||||
}
|
||||
|
||||
static bool_t match_right(const rect_t* widget, const rect_t* last_matched, const rect_t* iter) {
|
||||
if ((iter->x + iter->w / 2) < (widget->x + widget->w)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (last_matched == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (is_same_row(widget, iter)) {
|
||||
if (!is_same_row(widget, last_matched)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return iter->x < last_matched->x;
|
||||
}
|
||||
} else {
|
||||
return distance2(widget, iter) < distance2(widget, last_matched);
|
||||
}
|
||||
}
|
||||
|
||||
typedef bool_t (*match_focus_widget_t)(const rect_t* widget, const rect_t* last_matched,
|
||||
const rect_t* iter);
|
||||
|
||||
static widget_t* widget_find_matched_focus_widget(widget_t* widget, darray_t* all_focusable,
|
||||
match_focus_widget_t match) {
|
||||
uint32_t i = 0;
|
||||
point_t p = {0, 0};
|
||||
widget_t* matched = NULL;
|
||||
rect_t riter = {0, 0, 0, 0};
|
||||
rect_t rwidget = {0, 0, 0, 0};
|
||||
rect_t rmatched = {0, 0, 0, 0};
|
||||
|
||||
widget_to_global(widget, &p);
|
||||
rwidget = rect_init(p.x, p.y, widget->w, widget->h);
|
||||
|
||||
for (i = 0; i < all_focusable->size; i++) {
|
||||
widget_t* iter = WIDGET(all_focusable->elms[i]);
|
||||
if (iter == widget) {
|
||||
continue;
|
||||
}
|
||||
|
||||
p.x = 0;
|
||||
p.y = 0;
|
||||
widget_to_global(iter, &p);
|
||||
|
||||
riter = rect_init(p.x, p.y, iter->w, iter->h);
|
||||
if (match(&rwidget, (matched != NULL ? &rmatched : NULL), &riter)) {
|
||||
matched = iter;
|
||||
rmatched = riter;
|
||||
}
|
||||
}
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
static widget_t* widget_find_up_focus_widget(widget_t* widget, darray_t* all_focusable) {
|
||||
return widget_find_matched_focus_widget(widget, all_focusable, match_up);
|
||||
}
|
||||
|
||||
static widget_t* widget_find_down_focus_widget(widget_t* widget, darray_t* all_focusable) {
|
||||
return widget_find_matched_focus_widget(widget, all_focusable, match_down);
|
||||
}
|
||||
|
||||
static widget_t* widget_find_left_focus_widget(widget_t* widget, darray_t* all_focusable) {
|
||||
return widget_find_matched_focus_widget(widget, all_focusable, match_left);
|
||||
}
|
||||
|
||||
static widget_t* widget_find_right_focus_widget(widget_t* widget, darray_t* all_focusable) {
|
||||
return widget_find_matched_focus_widget(widget, all_focusable, match_right);
|
||||
}
|
||||
|
||||
ret_t widget_move_focus(widget_t* widget, widget_find_wanted_focus_widget_t find) {
|
||||
darray_t all_focusable;
|
||||
|
||||
if (widget == NULL || !widget->focused) {
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
||||
return_value_if_fail(find != NULL, RET_FAIL);
|
||||
return_value_if_fail(darray_init(&all_focusable, 10, NULL, NULL) != NULL, RET_OOM);
|
||||
|
||||
widget_get_all_focusable_widgets_in_window(widget, &all_focusable);
|
||||
if (all_focusable.size > 1) {
|
||||
widget_t* focus = find(widget, &all_focusable);
|
||||
|
||||
if (focus != NULL && focus != widget) {
|
||||
widget_set_prop_bool(widget, WIDGET_PROP_FOCUSED, FALSE);
|
||||
widget_set_prop_bool(focus, WIDGET_PROP_FOCUSED, TRUE);
|
||||
}
|
||||
}
|
||||
darray_deinit(&all_focusable);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t widget_focus_prev(widget_t* widget) {
|
||||
return widget_move_focus(widget, FALSE);
|
||||
return widget_move_focus(widget, widget_find_prev_focus_widget);
|
||||
}
|
||||
|
||||
ret_t widget_focus_next(widget_t* widget) {
|
||||
return widget_move_focus(widget, TRUE);
|
||||
return widget_move_focus(widget, widget_find_next_focus_widget);
|
||||
}
|
||||
|
||||
ret_t widget_focus_up(widget_t* widget) {
|
||||
return widget_move_focus(widget, widget_find_up_focus_widget);
|
||||
}
|
||||
|
||||
ret_t widget_focus_down(widget_t* widget) {
|
||||
return widget_move_focus(widget, widget_find_down_focus_widget);
|
||||
}
|
||||
|
||||
ret_t widget_focus_left(widget_t* widget) {
|
||||
return widget_move_focus(widget, widget_find_left_focus_widget);
|
||||
}
|
||||
|
||||
ret_t widget_focus_right(widget_t* widget) {
|
||||
return widget_move_focus(widget, widget_find_right_focus_widget);
|
||||
}
|
||||
|
||||
bool_t widget_is_window(widget_t* widget) {
|
||||
|
@ -2077,7 +2077,6 @@ bool_t widget_is_activate_key(widget_t* widget, key_event_t* e);
|
||||
|
||||
/*public for test*/
|
||||
ret_t widget_focus_first(widget_t* widget);
|
||||
ret_t widget_move_focus(widget_t* widget, bool_t next);
|
||||
locale_info_t* widget_get_locale_info(widget_t* widget);
|
||||
image_manager_t* widget_get_image_manager(widget_t* widget);
|
||||
assets_manager_t* widget_get_assets_manager(widget_t* widget);
|
||||
@ -2088,6 +2087,13 @@ ret_t widget_set_style(widget_t* widget, const char* state_and_name, const value
|
||||
ret_t widget_calc_icon_text_rect(const rect_t* ir, int32_t font_size, int32_t icon_at,
|
||||
int32_t spacer, rect_t* r_text, rect_t* r_icon);
|
||||
|
||||
ret_t widget_focus_prev(widget_t* widget);
|
||||
ret_t widget_focus_next(widget_t* widget);
|
||||
ret_t widget_focus_up(widget_t* widget);
|
||||
ret_t widget_focus_down(widget_t* widget);
|
||||
ret_t widget_focus_left(widget_t* widget);
|
||||
ret_t widget_focus_right(widget_t* widget);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_WIDGET_H*/
|
||||
|
@ -431,6 +431,12 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
#define WIDGET_PROP_MAX "max"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_GRAB_KEYS
|
||||
* 让窗口管理器直接把按键发给自己。
|
||||
*/
|
||||
#define WIDGET_PROP_GRAB_KEYS "grab_keys"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_ROW
|
||||
* 行数或每行的高度。
|
||||
@ -725,17 +731,41 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
#define WIDGET_PROP_WITH_FOCUS_STATE "with_focus_state"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_MOVE_FOCUS_PREV_KEY
|
||||
* 将焦点移到前一个的键值。
|
||||
*/
|
||||
#define WIDGET_PROP_MOVE_FOCUS_PREV_KEY "move_focus_prev_key"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_MOVE_FOCUS_NEXT_KEY
|
||||
* 将焦点移到下一个的键值。
|
||||
* 将焦点移到后一个的键值。
|
||||
*/
|
||||
#define WIDGET_PROP_MOVE_FOCUS_NEXT_KEY "move_focus_next_key"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_MOVE_FOCUS_PREV_KEY
|
||||
* 将焦点移到下一个的键值。
|
||||
* @const WIDGET_PROP_MOVE_FOCUS_UP_KEY
|
||||
* 将焦点向上移动的键值。
|
||||
*/
|
||||
#define WIDGET_PROP_MOVE_FOCUS_PREV_KEY "move_focus_prev_key"
|
||||
#define WIDGET_PROP_MOVE_FOCUS_UP_KEY "move_focus_up_key"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_MOVE_FOCUS_DOWN_KEY
|
||||
* 将焦点向下移动的键值。
|
||||
*/
|
||||
#define WIDGET_PROP_MOVE_FOCUS_DOWN_KEY "move_focus_down_key"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_MOVE_FOCUS_LEFT_KEY
|
||||
* 将焦点向左移动的键值。
|
||||
*/
|
||||
#define WIDGET_PROP_MOVE_FOCUS_LEFT_KEY "move_focus_left_key"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_MOVE_FOCUS_RIGHT_KEY
|
||||
* 将焦点向右移动的键值。
|
||||
*/
|
||||
#define WIDGET_PROP_MOVE_FOCUS_RIGHT_KEY "move_focus_right_key"
|
||||
|
||||
/**
|
||||
* @enum widget_type_t
|
||||
|
@ -141,10 +141,22 @@ ret_t window_base_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||
value_set_int(v, window_base->closable);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_PREV_KEY)) {
|
||||
value_set_int(v, window_base->move_focus_prev_key);
|
||||
value_set_str(v, window_base->move_focus_prev_key);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY)) {
|
||||
value_set_int(v, window_base->move_focus_next_key);
|
||||
value_set_str(v, window_base->move_focus_next_key);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_UP_KEY)) {
|
||||
value_set_str(v, window_base->move_focus_up_key);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_DOWN_KEY)) {
|
||||
value_set_str(v, window_base->move_focus_down_key);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_LEFT_KEY)) {
|
||||
value_set_str(v, window_base->move_focus_left_key);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_RIGHT_KEY)) {
|
||||
value_set_str(v, window_base->move_focus_right_key);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -172,28 +184,23 @@ ret_t window_base_set_prop(widget_t* widget, const char* name, const value_t* v)
|
||||
window_base->theme = tk_str_copy(window_base->theme, value_str(v));
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_PREV_KEY)) {
|
||||
if (v->type == VALUE_TYPE_STRING) {
|
||||
const key_type_value_t* kv = keys_type_find(value_str(v));
|
||||
if (kv != NULL) {
|
||||
window_base->move_focus_prev_key = kv->value;
|
||||
} else {
|
||||
log_debug("invalid key: %s\n", value_str(v));
|
||||
}
|
||||
} else {
|
||||
window_base->move_focus_prev_key = value_int(v);
|
||||
}
|
||||
window_base->move_focus_prev_key = tk_str_copy(window_base->move_focus_prev_key, value_str(v));
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY)) {
|
||||
if (v->type == VALUE_TYPE_STRING) {
|
||||
const key_type_value_t* kv = keys_type_find(value_str(v));
|
||||
if (kv != NULL) {
|
||||
window_base->move_focus_next_key = kv->value;
|
||||
} else {
|
||||
log_debug("invalid key: %s\n", value_str(v));
|
||||
}
|
||||
} else {
|
||||
window_base->move_focus_next_key = value_int(v);
|
||||
}
|
||||
window_base->move_focus_next_key = tk_str_copy(window_base->move_focus_next_key, value_str(v));
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_UP_KEY)) {
|
||||
window_base->move_focus_up_key = tk_str_copy(window_base->move_focus_up_key, value_str(v));
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_DOWN_KEY)) {
|
||||
window_base->move_focus_down_key = tk_str_copy(window_base->move_focus_down_key, value_str(v));
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_LEFT_KEY)) {
|
||||
window_base->move_focus_left_key = tk_str_copy(window_base->move_focus_left_key, value_str(v));
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_MOVE_FOCUS_RIGHT_KEY)) {
|
||||
window_base->move_focus_right_key =
|
||||
tk_str_copy(window_base->move_focus_right_key, value_str(v));
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_CLOSABLE)) {
|
||||
if (v->type == VALUE_TYPE_STRING) {
|
||||
@ -217,6 +224,12 @@ ret_t window_base_on_destroy(widget_t* widget) {
|
||||
TKMEM_FREE(window_base->theme);
|
||||
TKMEM_FREE(window_base->open_anim_hint);
|
||||
TKMEM_FREE(window_base->close_anim_hint);
|
||||
TKMEM_FREE(window_base->move_focus_prev_key);
|
||||
TKMEM_FREE(window_base->move_focus_next_key);
|
||||
TKMEM_FREE(window_base->move_focus_up_key);
|
||||
TKMEM_FREE(window_base->move_focus_down_key);
|
||||
TKMEM_FREE(window_base->move_focus_left_key);
|
||||
TKMEM_FREE(window_base->move_focus_right_key);
|
||||
|
||||
window_base_unload_theme_obj(widget);
|
||||
|
||||
@ -275,8 +288,9 @@ widget_t* window_base_create(widget_t* parent, const widget_vtable_t* vt, xy_t x
|
||||
|
||||
return_value_if_fail(window_manager_open_window(parent, widget) == RET_OK, NULL);
|
||||
win->stage = WINDOW_STAGE_NONE;
|
||||
win->move_focus_next_key = TK_KEY_MOVE_FOCUS_NEXT;
|
||||
win->move_focus_prev_key = TK_KEY_MOVE_FOCUS_PREV;
|
||||
win->move_focus_prev_key = NULL;
|
||||
win->move_focus_next_key = tk_strdup(TK_KEY_MOVE_FOCUS_NEXT);
|
||||
|
||||
#ifdef ENABLE_MEM_LEAK_CHECK
|
||||
tk_mem_dump();
|
||||
#endif /*ENABLE_MEM_LEAK_CHECK*/
|
||||
|
@ -135,11 +135,63 @@ typedef struct _window_base_t {
|
||||
* 把资源管理器对象与窗口关联起来,是为了解决UI设计器与被设计的窗口需要从不同的位置加载资源资源的问题。
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {char*} move_focus_prev_key
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||
* 向前移动焦点的键值。
|
||||
*
|
||||
* 请参考[控件焦点](https://github.com/zlgopen/awtk/blob/master/docs/widget_focus.md)
|
||||
*/
|
||||
char* move_focus_prev_key;
|
||||
|
||||
/**
|
||||
* @property {char*} move_focus_next_key
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||
* 向后移动焦点的键值。
|
||||
*
|
||||
* 请参考[控件焦点](https://github.com/zlgopen/awtk/blob/master/docs/widget_focus.md)
|
||||
*/
|
||||
char* move_focus_next_key;
|
||||
|
||||
/**
|
||||
* @property {char*} move_focus_up_key
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||
* 向上移动焦点的键值。
|
||||
*
|
||||
* 请参考[控件焦点](https://github.com/zlgopen/awtk/blob/master/docs/widget_focus.md)
|
||||
*/
|
||||
char* move_focus_up_key;
|
||||
|
||||
/**
|
||||
* @property {char*} move_focus_down_key
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||
* 向下移动焦点的键值。
|
||||
*
|
||||
* 请参考[控件焦点](https://github.com/zlgopen/awtk/blob/master/docs/widget_focus.md)
|
||||
*/
|
||||
char* move_focus_down_key;
|
||||
|
||||
/**
|
||||
* @property {char*} move_focus_left_key
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||
* 向左移动焦点的键值。
|
||||
*
|
||||
* 请参考[控件焦点](https://github.com/zlgopen/awtk/blob/master/docs/widget_focus.md)
|
||||
*/
|
||||
char* move_focus_left_key;
|
||||
|
||||
/**
|
||||
* @property {char*} move_focus_right_key
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||
* 向右移动焦点的键值。
|
||||
*
|
||||
* 请参考[控件焦点](https://github.com/zlgopen/awtk/blob/master/docs/widget_focus.md)
|
||||
*/
|
||||
char* move_focus_right_key;
|
||||
|
||||
/*private*/
|
||||
const asset_info_t* res_theme;
|
||||
font_manager_t* font_manager;
|
||||
int32_t move_focus_prev_key;
|
||||
int32_t move_focus_next_key;
|
||||
native_window_t* native_window;
|
||||
} window_base_t;
|
||||
|
||||
|
@ -247,6 +247,9 @@ ret_t window_manager_dispatch_input_event(widget_t* widget, event_t* e) {
|
||||
return_value_if_fail(e != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(wm != NULL && wm->vt != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(wm->vt->dispatch_input_event != NULL, RET_BAD_PARAMS);
|
||||
if (widget_dispatch(widget, e) == RET_STOP) {
|
||||
return RET_STOP;
|
||||
}
|
||||
|
||||
return wm->vt->dispatch_input_event(widget, e);
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ ret_t ubjson_writer_write_noop(ubjson_writer_t* writer);
|
||||
*/
|
||||
ret_t ubjson_writer_write_true(ubjson_writer_t* writer);
|
||||
|
||||
|
||||
/**
|
||||
* @method ubjson_writer_write_false
|
||||
*
|
||||
@ -233,7 +232,6 @@ ret_t ubjson_writer_write_char(ubjson_writer_t* writer, char value);
|
||||
*/
|
||||
ret_t ubjson_writer_write_str(ubjson_writer_t* writer, const char* value);
|
||||
|
||||
|
||||
/**
|
||||
* @method ubjson_writer_write_str_len
|
||||
*
|
||||
@ -393,7 +391,6 @@ ret_t ubjson_writer_write_kv_int64(ubjson_writer_t* writer, const char* key, int
|
||||
*/
|
||||
ret_t ubjson_writer_write_kv_float(ubjson_writer_t* writer, const char* key, float value);
|
||||
|
||||
|
||||
/**
|
||||
* @method ubjson_writer_write_kv_double
|
||||
*
|
||||
|
@ -887,15 +887,15 @@ TEST(Widget, move_focus) {
|
||||
|
||||
widget_set_focused(b1, TRUE);
|
||||
ASSERT_EQ(b1->focused, TRUE);
|
||||
ASSERT_EQ(widget_move_focus(b1, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b1), RET_OK);
|
||||
ASSERT_EQ(b1->focused, FALSE);
|
||||
ASSERT_EQ(b2->focused, TRUE);
|
||||
|
||||
ASSERT_EQ(widget_move_focus(b2, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b2), RET_OK);
|
||||
ASSERT_EQ(b2->focused, FALSE);
|
||||
ASSERT_EQ(b3->focused, TRUE);
|
||||
|
||||
ASSERT_EQ(widget_move_focus(b3, FALSE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_prev(b3), RET_OK);
|
||||
ASSERT_EQ(b3->focused, FALSE);
|
||||
ASSERT_EQ(b2->focused, TRUE);
|
||||
|
||||
@ -921,15 +921,15 @@ TEST(Widget, move_focus_skip_invisible) {
|
||||
|
||||
widget_set_focused(b1, TRUE);
|
||||
ASSERT_EQ(b1->focused, TRUE);
|
||||
ASSERT_EQ(widget_move_focus(b1, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b1), RET_OK);
|
||||
ASSERT_EQ(b1->focused, FALSE);
|
||||
ASSERT_EQ(b2->focused, TRUE);
|
||||
|
||||
ASSERT_EQ(widget_move_focus(b2, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b2), RET_OK);
|
||||
ASSERT_EQ(b2->focused, FALSE);
|
||||
ASSERT_EQ(b3->focused, TRUE);
|
||||
|
||||
ASSERT_EQ(widget_move_focus(b3, FALSE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_prev(b3), RET_OK);
|
||||
ASSERT_EQ(b3->focused, FALSE);
|
||||
ASSERT_EQ(b2->focused, TRUE);
|
||||
|
||||
@ -957,7 +957,7 @@ TEST(Widget, move_focus_first) {
|
||||
widget_focus_first(w);
|
||||
ASSERT_EQ(widget_has_focused_widget_in_window(w), TRUE);
|
||||
ASSERT_EQ(b1->focused, TRUE);
|
||||
ASSERT_EQ(widget_move_focus(b1, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b1), RET_OK);
|
||||
ASSERT_EQ(b1->focused, FALSE);
|
||||
ASSERT_EQ(b2->focused, TRUE);
|
||||
|
||||
@ -985,22 +985,22 @@ TEST(Widget, move_focus_pages) {
|
||||
|
||||
widget_focus_first(w);
|
||||
ASSERT_EQ(b0->focused, TRUE);
|
||||
ASSERT_EQ(widget_move_focus(b0, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b0), RET_OK);
|
||||
ASSERT_EQ(b0->focused, FALSE);
|
||||
ASSERT_EQ(b1->focused, TRUE);
|
||||
|
||||
ASSERT_EQ(widget_move_focus(b1, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b1), RET_OK);
|
||||
ASSERT_EQ(b1->focused, FALSE);
|
||||
ASSERT_EQ(b0->focused, TRUE);
|
||||
|
||||
pages_set_active(pages, 1);
|
||||
widget_focus_first(w);
|
||||
ASSERT_EQ(b0->focused, TRUE);
|
||||
ASSERT_EQ(widget_move_focus(b0, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b0), RET_OK);
|
||||
ASSERT_EQ(b0->focused, FALSE);
|
||||
ASSERT_EQ(b2->focused, TRUE);
|
||||
|
||||
ASSERT_EQ(widget_move_focus(b2, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_focus_next(b2), RET_OK);
|
||||
ASSERT_EQ(b2->focused, FALSE);
|
||||
ASSERT_EQ(b0->focused, TRUE);
|
||||
widget_destroy(w);
|
||||
|
@ -48,26 +48,11 @@ TEST(Window, basic) {
|
||||
TEST(Window, focus_key) {
|
||||
widget_t* w = window_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, 0), TK_KEY_MOVE_FOCUS_PREV);
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, 0), TK_KEY_MOVE_FOCUS_NEXT);
|
||||
|
||||
ASSERT_EQ(widget_set_prop_int(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, TK_KEY_LEFT), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, 0), TK_KEY_LEFT);
|
||||
|
||||
ASSERT_EQ(widget_set_prop_int(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, TK_KEY_RIGHT), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, 0), TK_KEY_RIGHT);
|
||||
|
||||
ASSERT_EQ(widget_set_prop_str(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, "UP"), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, 0), TK_KEY_UP);
|
||||
ASSERT_STREQ(widget_get_prop_str(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, 0), "UP");
|
||||
|
||||
ASSERT_EQ(widget_set_prop_str(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, "DOWN"), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, 0), TK_KEY_DOWN);
|
||||
|
||||
ASSERT_EQ(widget_set_prop_str(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, "up"), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_PREV_KEY, 0), TK_KEY_UP);
|
||||
|
||||
ASSERT_EQ(widget_set_prop_str(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, "down"), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, 0), TK_KEY_DOWN);
|
||||
ASSERT_STREQ(widget_get_prop_str(w, WIDGET_PROP_MOVE_FOCUS_NEXT_KEY, 0), "DOWN");
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user