MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / eventOccured

Method eventOccured

forms/textedit.cpp:33–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31bool TextEdit::isFocused() const { return editing; }
32
33void TextEdit::eventOccured(Event *e)
34{
35 UString keyname;
36
37 Control::eventOccured(e);
38
39 if (e->type() == EVENT_FORM_INTERACTION)
40 {
41 if (e->forms().RaisedBy == shared_from_this())
42 {
43 if (e->forms().EventFlag == FormEventType::GotFocus ||
44 e->forms().EventFlag == FormEventType::MouseClick ||
45 e->forms().EventFlag == FormEventType::KeyDown)
46 {
47 if (!editing)
48 {
49 editing = true;
50 fw().textStartInput();
51 // e->Handled = true;
52 // FIXME: Should we really fall through here?
53 }
54 }
55 }
56 if (editing)
57 {
58 if (e->forms().RaisedBy == shared_from_this())
59 {
60 if (e->forms().EventFlag == FormEventType::LostFocus)
61 {
62 editing = false;
63 fw().textStopInput();
64 raiseEvent(FormEventType::TextEditFinish);
65 // e->Handled = true;
66 }
67 }
68 else if (e->forms().EventFlag == FormEventType::MouseClick)
69 {
70 // FIXME: Due to event duplication (?), this code won't work. Can only stop editing
71 // text by pressing enter.
72 // editing = false;
73 // fw().textStopInput();
74 // raiseEvent(FormEventType::TextEditFinish);
75 }
76 if (e->forms().EventFlag == FormEventType::KeyDown)
77 {
78 LogInfo("Key pressed: %d", e->forms().KeyInfo.KeyCode);
79 switch (e->forms().KeyInfo.KeyCode)
80 {
81 case SDLK_BACKSPACE:
82 if (SelectionStart > 0)
83 {
84 text = remove(text, SelectionStart - 1, 1);
85 SelectionStart--;
86 raiseEvent(FormEventType::TextChanged);
87 }
88 e->Handled = true;
89 break;
90 case SDLK_DELETE:

Callers

nothing calls this directly

Calls 8

removeFunction · 0.85
to_u32stringFunction · 0.85
typeMethod · 0.80
textStartInputMethod · 0.80
textStopInputMethod · 0.80
textGetClipboardMethod · 0.80
emptyMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected