-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUiMyStaticText.cpp
38 lines (31 loc) · 1.18 KB
/
UiMyStaticText.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
#include "UiSystem.h" // sharing info between Ui* wxgui modules
#include "UiMyStaticText.h" // sharing info between UI_wxgui modules
MyStaticText::MyStaticText(wxWindow* parent, wxWindowID id,
const wxString &label)
: wxStaticText(parent, id, label)
{
// event routing table
Bind(wxEVT_KEY_DOWN, &MyStaticText::OnKeyDown, this);
Bind(wxEVT_LEFT_DOWN, &MyStaticText::OnMouseClick, this);
Bind(wxEVT_MIDDLE_DOWN, &MyStaticText::OnMouseClick, this);
Bind(wxEVT_RIGHT_DOWN, &MyStaticText::OnMouseClick, this);
}
// redirect mouse clicks to parent dialog
void MyStaticText::OnMouseClick(wxMouseEvent &event)
{
GetParent()->GetEventHandler()->AddPendingEvent(event);
}
// make RETURN key kill the dialog too
void MyStaticText::OnKeyDown(wxKeyEvent &event)
{
const int wxKey = event.GetKeyCode();
if (wxKey == WXK_RETURN) {
// fabricate a left click and send it to the dialog
// this will cause it to shut down
wxMouseEvent evt(wxEVT_LEFT_DOWN);
GetParent()->GetEventHandler()->AddPendingEvent(evt);
} else {
event.Skip();
}
}
// vim: ts=8:et:sw=4:smarttab