mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
button add enable_long_press property
This commit is contained in:
parent
d84dd7a436
commit
dc00e9a674
@ -1,5 +1,5 @@
|
||||
const unsigned char ui_button[] = {
|
||||
0x04,0x00,0x01,0x01,0x96,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x64,
|
||||
0x04,0x00,0x01,0x01,0xdb,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x64,
|
||||
0x61,0x74,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,
|
||||
@ -9,55 +9,58 @@ const unsigned char ui_button[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x80,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,0x31,0x32,0x38,
|
||||
0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x72,0x6f,0x75,0x6e,0x64,0x00,0x74,
|
||||
0x65,0x78,0x74,0x00,0x54,0x65,0x78,0x74,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,
|
||||
0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x72,0x6f,0x75,0x6e,0x64,0x00,0x65,
|
||||
0x6e,0x61,0x62,0x6c,0x65,0x5f,0x6c,0x6f,0x6e,0x67,0x5f,0x70,0x72,0x65,0x73,0x73,0x00,0x74,0x72,0x75,
|
||||
0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x54,0x65,0x78,0x74,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,0x32,0x00,0x00,0x00,0x80,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,0x35,0x30,0x2c,0x77,0x3d,0x31,0x32,0x38,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,
|
||||
0x73,0x74,0x79,0x6c,0x65,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x54,
|
||||
0x65,0x78,0x74,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,0x32,0x00,0x00,0x00,0x80,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,0x35,0x30,0x2c,0x77,0x3d,0x31,0x32,0x38,0x2c,0x68,0x3d,0x33,
|
||||
0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x00,0x65,0x6e,0x61,
|
||||
0x62,0x6c,0x65,0x5f,0x6c,0x6f,0x6e,0x67,0x5f,0x70,0x72,0x65,0x73,0x73,0x00,0x74,0x72,0x75,0x65,0x00,
|
||||
0x74,0x65,0x78,0x74,0x00,0x54,0x65,0x78,0x74,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,0x5a,0x00,0x00,0x00,0x80,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,
|
||||
0x39,0x30,0x2c,0x77,0x3d,0x31,0x32,0x38,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,
|
||||
0x00,0x69,0x63,0x6f,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x54,0x65,0x78,0x74,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,0x82,0x00,0x00,0x00,0x80,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,0x33,0x30,0x2c,0x77,0x3d,0x31,0x32,
|
||||
0x38,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x00,0x6c,0x61,0x62,0x65,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x64,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,0x30,
|
||||
0x2c,0x79,0x3d,0x30,0x2c,0x77,0x3d,0x31,0x30,0x30,0x25,0x2c,0x68,0x3d,0x31,0x30,0x30,0x25,0x29,0x00,
|
||||
0x74,0x65,0x78,0x74,0x00,0x54,0x65,0x78,0x74,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x64,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5a,0x00,0x00,0x00,0x80,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,0x72,0x69,0x67,0x68,0x74,0x2c,0x79,0x3d,0x30,0x2c,0x77,0x3d,0x33,0x30,0x2c,0x68,0x3d,0x31,
|
||||
0x30,0x30,0x25,0x29,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x65,0x61,0x72,0x74,0x68,0x00,0x64,0x72,0x61,
|
||||
0x77,0x5f,0x74,0x79,0x70,0x65,0x00,0x69,0x63,0x6f,0x6e,0x00,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,0xaa,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x3c,
|
||||
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,0x37,0x30,0x2c,0x77,0x3d,0x36,0x30,0x2c,0x68,0x3d,
|
||||
0x36,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x63,0x6f,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,
|
||||
0x78,0x3d,0x63,0x2c,0x79,0x3d,0x39,0x30,0x2c,0x77,0x3d,0x31,0x32,0x38,0x2c,0x68,0x3d,0x33,0x30,0x29,
|
||||
0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x63,0x6f,0x6e,0x00,0x65,0x6e,0x61,0x62,0x6c,0x65,0x5f,0x6c,
|
||||
0x6f,0x6e,0x67,0x5f,0x70,0x72,0x65,0x73,0x73,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x65,0x78,0x74,0x00,
|
||||
0x54,0x65,0x78,0x74,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,0xf0,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,
|
||||
0x00,0x00,0x00,0x82,0x00,0x00,0x00,0x80,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,0x32,0x34,0x30,0x2c,0x77,0x3d,0x36,0x30,0x2c,0x68,0x3d,0x36,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,
|
||||
0x65,0x00,0x69,0x63,0x6f,0x6e,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,
|
||||
0x3d,0x31,0x33,0x30,0x2c,0x77,0x3d,0x31,0x32,0x38,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x00,0x6c,0x61,
|
||||
0x62,0x65,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x00,
|
||||
0x00,0x00,0x64,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,0x30,0x2c,0x79,0x3d,0x30,0x2c,0x77,0x3d,0x31,0x30,0x30,0x25,
|
||||
0x2c,0x68,0x3d,0x31,0x30,0x30,0x25,0x29,0x00,0x74,0x65,0x78,0x74,0x00,0x54,0x65,0x78,0x74,0x00,0x00,
|
||||
0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x36,0x01,0x00,0x00,0x1e,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,0x33,0x31,0x30,0x2c,0x77,0x3d,0x33,0x30,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x73,0x74,
|
||||
0x79,0x6c,0x65,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,
|
||||
0x00,0x1e,0x00,0x00,0x00,0x64,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,0x72,0x69,0x67,0x68,0x74,0x2c,0x79,0x3d,0x30,
|
||||
0x2c,0x77,0x3d,0x33,0x30,0x2c,0x68,0x3d,0x31,0x30,0x30,0x25,0x29,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,
|
||||
0x65,0x61,0x72,0x74,0x68,0x00,0x64,0x72,0x61,0x77,0x5f,0x74,0x79,0x70,0x65,0x00,0x69,0x63,0x6f,0x6e,
|
||||
0x00,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,0x19,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,0x65,0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x31,0x30,
|
||||
0x2c,0x77,0x3d,0x32,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,0x6c,
|
||||
0x6f,0x73,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,0x6f,0x73,0x65,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,};/*1222*/
|
||||
0xaa,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x3c,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,0x37,
|
||||
0x30,0x2c,0x77,0x3d,0x36,0x30,0x2c,0x68,0x3d,0x36,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,
|
||||
0x63,0x6f,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x54,0x65,0x78,0x74,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,0xf0,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,
|
||||
0x3c,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,0x32,0x34,0x30,0x2c,0x77,0x3d,0x36,0x30,0x2c,0x68,
|
||||
0x3d,0x36,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x63,0x6f,0x6e,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,0x36,0x01,0x00,0x00,0x1e,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,0x33,0x31,0x30,0x2c,0x77,0x3d,0x33,0x30,
|
||||
0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x6d,0x61,0x67,0x65,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,0x19,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,0x65,0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,
|
||||
0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x31,0x30,0x2c,0x77,0x3d,0x32,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,
|
||||
0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,0x6c,0x6f,0x73,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,
|
||||
0x6f,0x73,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*1291*/
|
||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
<window anim_hint="htranslate">
|
||||
<button style="round" x="c" y="10" w="128" h="30" text="Text"/>
|
||||
<button style="red_btn" x="c" y="50" w="128" h="30" text="Text"/>
|
||||
<button style="icon" x="c" y="90" w="128" h="30" text="Text"/>
|
||||
<button style="round" enable_long_press="true" x="c" y="10" w="128" h="30" text="Text"/>
|
||||
<button style="red_btn" enable_long_press="true" x="c" y="50" w="128" h="30" text="Text"/>
|
||||
<button style="icon" enable_long_press="true" x="c" y="90" w="128" h="30" text="Text"/>
|
||||
<button x="c" y="130" w="128" h="30">
|
||||
<label y="0" x="0" w="100%" h="100%" text="Text"/>
|
||||
<image image="earth" draw_type="icon" y="0" x="right" w="30" h="100%"/>
|
||||
|
@ -1,4 +1,7 @@
|
||||
# 最新动态
|
||||
* 2019/02/20
|
||||
* 按钮增加enable\_long\_press属性用于启用长按事件,触发长按事件后不再触发点击事件。
|
||||
|
||||
* 2019/02/19
|
||||
* add darray\_tail/darray\_head。
|
||||
|
||||
|
@ -461,6 +461,12 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
#define WIDGET_PROP_REPEAT "repeat"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_ENABLE_LONG_PRESS
|
||||
*
|
||||
*/
|
||||
#define WIDGET_PROP_ENABLE_LONG_PRESS "enable_long_press"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_ANIMATABLE
|
||||
*
|
||||
|
@ -49,6 +49,17 @@ static ret_t button_on_repeat(const timer_info_t* info) {
|
||||
return RET_REPEAT;
|
||||
}
|
||||
|
||||
static ret_t button_pointer_up_cleanup(widget_t* widget) {
|
||||
button_t* button = BUTTON(widget);
|
||||
|
||||
button->pressed = FALSE;
|
||||
button_remove_timer(widget);
|
||||
widget_ungrab(widget->parent, widget);
|
||||
widget_set_state(widget, WIDGET_STATE_NORMAL);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t button_on_long_press(const timer_info_t* info) {
|
||||
pointer_event_t evt;
|
||||
widget_t* widget = WIDGET(info->ctx);
|
||||
@ -59,21 +70,11 @@ static ret_t button_on_long_press(const timer_info_t* info) {
|
||||
|
||||
button_remove_timer(widget);
|
||||
widget_dispatch(widget, (event_t*)&evt);
|
||||
button_pointer_up_cleanup(widget);
|
||||
|
||||
return RET_REMOVE;
|
||||
}
|
||||
|
||||
static ret_t button_pointer_up_cleanup(widget_t* widget) {
|
||||
button_t* button = BUTTON(widget);
|
||||
|
||||
button->pressed = FALSE;
|
||||
button_remove_timer(widget);
|
||||
widget_ungrab(widget->parent, widget);
|
||||
widget_set_state(widget, WIDGET_STATE_NORMAL);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t button_on_event(widget_t* widget, event_t* e) {
|
||||
uint16_t type = e->type;
|
||||
button_t* button = BUTTON(widget);
|
||||
@ -86,7 +87,7 @@ static ret_t button_on_event(widget_t* widget, event_t* e) {
|
||||
button_remove_timer(widget);
|
||||
if (button->repeat > 0) {
|
||||
button->timer_id = timer_add(button_on_repeat, widget, button->repeat);
|
||||
} else {
|
||||
} else if (button->enable_long_press) {
|
||||
button->timer_id = timer_add(button_on_long_press, widget, TK_LONG_PRESS_TIME);
|
||||
}
|
||||
|
||||
@ -135,6 +136,15 @@ ret_t button_set_repeat(widget_t* widget, int32_t repeat) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t button_set_enable_long_press(widget_t* widget, bool_t enable_long_press) {
|
||||
button_t* button = BUTTON(widget);
|
||||
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
|
||||
|
||||
button->enable_long_press = enable_long_press;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t button_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||
button_t* button = BUTTON(widget);
|
||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
||||
@ -142,6 +152,9 @@ static ret_t button_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||
if (tk_str_eq(name, WIDGET_PROP_REPEAT)) {
|
||||
value_set_int(v, button->repeat);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_ENABLE_LONG_PRESS)) {
|
||||
value_set_bool(v, button->enable_long_press);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
return RET_NOT_FOUND;
|
||||
@ -153,6 +166,9 @@ static ret_t button_get_prop_default_value(widget_t* widget, const char* name, v
|
||||
if (tk_str_eq(name, WIDGET_PROP_REPEAT)) {
|
||||
value_set_int(v, 0);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_ENABLE_LONG_PRESS)) {
|
||||
value_set_bool(v, FALSE);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
return RET_NOT_FOUND;
|
||||
@ -163,6 +179,8 @@ static ret_t button_set_prop(widget_t* widget, const char* name, const value_t*
|
||||
|
||||
if (tk_str_eq(name, WIDGET_PROP_REPEAT)) {
|
||||
return button_set_repeat(widget, value_int(v));
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_ENABLE_LONG_PRESS)) {
|
||||
return button_set_enable_long_press(widget, value_bool(v));
|
||||
}
|
||||
|
||||
return RET_NOT_FOUND;
|
||||
@ -195,6 +213,7 @@ widget_t* button_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
button->repeat = 0;
|
||||
button->repeat_nr = 0;
|
||||
button->pressed = FALSE;
|
||||
button->enable_long_press = FALSE;
|
||||
button->timer_id = TK_INVALID_ID;
|
||||
|
||||
return widget;
|
||||
|
@ -85,6 +85,17 @@ typedef struct _button_t {
|
||||
*/
|
||||
int32_t repeat;
|
||||
|
||||
/**
|
||||
* @property {bool_t} enable_long_press
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
*
|
||||
* 是否启用长按事件,为true时才触发长按事件。
|
||||
* 触发长按事件后不再触发点击事件。
|
||||
* 缺省不启用。
|
||||
*
|
||||
*/
|
||||
bool_t enable_long_press;
|
||||
|
||||
/*private*/
|
||||
int32_t timer_id;
|
||||
int32_t repeat_nr;
|
||||
@ -136,6 +147,17 @@ widget_t* button_cast(widget_t* widget);
|
||||
*/
|
||||
ret_t button_set_repeat(widget_t* widget, int32_t repeat);
|
||||
|
||||
/**
|
||||
* @method button_set_enable_long_press
|
||||
* 设置是否启用长按事件。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget 控件对象。
|
||||
* @param {bool_t} enable_long_press 是否启用长按事件。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t button_set_enable_long_press(widget_t* widget, bool_t enable_long_press);
|
||||
|
||||
#define BUTTON(widget) ((button_t*)(widget))
|
||||
|
||||
END_C_DECLS
|
||||
|
@ -31,6 +31,11 @@ TEST(Button, basic) {
|
||||
ASSERT_EQ(widget_get_prop(w, WIDGET_PROP_REPEAT, &v2), RET_OK);
|
||||
ASSERT_EQ(value_int(&v1), value_int(&v2));
|
||||
|
||||
value_set_bool(&v1, TRUE);
|
||||
ASSERT_EQ(widget_set_prop_str(w, WIDGET_PROP_ENABLE_LONG_PRESS, "true"), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop(w, WIDGET_PROP_ENABLE_LONG_PRESS, &v2), RET_OK);
|
||||
ASSERT_EQ(value_bool(&v1), value_bool(&v2));
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user