-
Notifications
You must be signed in to change notification settings - Fork 3
/
InputEvent.cpp
80 lines (71 loc) · 1.76 KB
/
InputEvent.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//-----本文件是键盘事件的响应-----
#include "widget.h"
#include "configure.h"
void Widget::PassMousePressEvent(Pos point)
{
QMouseEvent e(QEvent::Type::MouseButtonPress,point,Qt::MouseButton::LeftButton,nullptr,nullptr);
this->mousePressEvent(&e);
}
void Widget::PassMouseReleaseEvent(Pos point)
{
QMouseEvent e(QEvent::Type::MouseButtonRelease,point,Qt::MouseButton::LeftButton,nullptr,nullptr);
this->mouseReleaseEvent(&e);
}
void Widget::PassMouseMoveEvent(QMouseEvent *e)
{this->mouseMoveEvent(e);}
void Widget::keyPressEvent(QKeyEvent *e)//键盘事件响应
{
for(InputEvent &i:AllEvent)
{
if(i.key==e->key())
{
RunFun(i.PressFun,i.PressPar);
return;
}
}
}
void Widget::mousePressEvent(QMouseEvent *e)//鼠标事件响应
{
for(InputEvent &i:AllEvent)
{
if(i.mouseX<=e->x()&&i.mouseY<=e->y()&&i.fmouseY>=e->y()&&i.fmouseX>=e->x())
{RunFun(i.PressFun,i.PressPar);}
}
}
void Widget::keyReleaseEvent(QKeyEvent *e)
{
for(InputEvent &i:AllEvent)
{
if(i.key==e->key())
{
RunFun(i.ReleaseFun,i.ReleasePar);
return;
}
}
}
void Widget::mouseReleaseEvent(QMouseEvent *e)
{
for(InputEvent &i:AllEvent)
{
if(i.mouseX<=e->x()&&i.mouseY<=e->y()&&i.fmouseY>=e->y()&&i.fmouseX>=e->x())
{RunFun(i.ReleaseFun,i.ReleasePar);}
}
}
void Widget::mouseMoveEvent(QMouseEvent *e)
{
for(GestureArea* gesarea:AllGestureArea)
{
for(Gesture* ges:gesarea->allGesture)
{ges->match(e->pos());}
}
}
#ifdef AutoIsColliding
void Widget::itemMoveEvent()
{
for(Collision &co:AllAutoCollision)
{
if(ItemColliding(co.item1,co.item2))
{RunFun(co.slot,co.par);}
}
}
#endif