为部件事件添加 screen_x 和 screen_y 属性

This commit is contained in:
Liu Chao
2016-03-06 20:34:35 +08:00
parent fc72a6bbc8
commit a8da5066f4
2 changed files with 5 additions and 3 deletions
+2 -1
View File
@@ -74,7 +74,8 @@ typedef struct LCUI_WidgetEvent {
int type; /**< 事件类型标识号 */
const char *type_name; /**< 事件类型名称 */
int which; /**< 指示按了哪个键或按钮 */
int x, y; /**< 鼠标的坐标(相对于当前部件的边框盒) */
int x, y; /**< 事件触发时鼠标的坐标(相对于当前部件的边框盒) */
int screen_x, screen_y; /**< 事件触发时鼠标的屏幕坐标 */
void *data; /**< 附加数据 */
LCUI_Widget target; /**< 触发事件的部件 */
LCUI_BOOL cancel_bubble; /**< 是否取消事件冒泡 */
+3 -2
View File
@@ -348,6 +348,8 @@ static void OnMouseEvent( LCUI_SystemEvent *e, void *arg )
ebuff.cancel_bubble = FALSE;
ebuff.x = pos.x - ebuff.x;
ebuff.y = pos.y - ebuff.y;
ebuff.screen_x = pos.x;
ebuff.screen_y = pos.y;
ebuff.target = target;
ebuff.which = 0;
switch( e->type ) {
@@ -361,10 +363,9 @@ static void OnMouseEvent( LCUI_SystemEvent *e, void *arg )
ebuff.type = WET_MOUSEUP;
ebuff.type_name = "mouseup";
Widget_PostEvent( target, &ebuff, NULL );
_DEBUG_MSG( "target: %s, prev: %s\n", target->type,
DEBUG_MSG( "target: %s, prev: %s\n", target->type,
self.targets[WST_ACTIVE] ? self.targets[WST_ACTIVE]->type :"null" );
if( self.targets[WST_ACTIVE] == target ) {
_DEBUG_MSG("post click event\n");
ebuff.type = WET_CLICK;
ebuff.type_name = "click";
Widget_PostEvent( target, &ebuff, NULL );