MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / OnClick

Method OnClick

src/osk_gui.cpp:107–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105 }
106
107 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
108 {
109 /* clicked a letter */
110 if (widget >= WID_OSK_LETTERS) {
111 char32_t c = _keyboard[this->shift][widget - WID_OSK_LETTERS];
112
113 if (!IsValidChar(c, this->qs->text.afilter)) return;
114
115 if (this->qs->text.InsertChar(c)) this->OnEditboxChanged(WID_OSK_TEXT);
116
117 if (HasBit(_keystate, KEYS_SHIFT)) {
118 ToggleBit(_keystate, KEYS_SHIFT);
119 this->UpdateOskState();
120 this->SetDirty();
121 }
122 return;
123 }
124
125 switch (widget) {
126 case WID_OSK_BACKSPACE:
127 if (this->qs->text.DeleteChar(WKC_BACKSPACE)) this->OnEditboxChanged(WID_OSK_TEXT);
128 break;
129
130 case WID_OSK_SPECIAL:
131 /*
132 * Anything device specific can go here.
133 * The button itself is hidden by default, and when you need it you
134 * can not hide it in the create event.
135 */
136 break;
137
138 case WID_OSK_CAPS:
139 ToggleBit(_keystate, KEYS_CAPS);
140 this->UpdateOskState();
141 this->SetDirty();
142 break;
143
144 case WID_OSK_SHIFT:
145 ToggleBit(_keystate, KEYS_SHIFT);
146 this->UpdateOskState();
147 this->SetDirty();
148 break;
149
150 case WID_OSK_SPACE:
151 if (this->qs->text.InsertChar(' ')) this->OnEditboxChanged(WID_OSK_TEXT);
152 break;
153
154 case WID_OSK_LEFT:
155 if (this->qs->text.MovePos(WKC_LEFT)) this->InvalidateData();
156 break;
157
158 case WID_OSK_RIGHT:
159 if (this->qs->text.MovePos(WKC_RIGHT)) this->InvalidateData();
160 break;
161
162 case WID_OSK_OK:
163 if (!this->qs->orig.has_value() || this->qs->text.GetText() != this->qs->orig) {
164 /* pass information by simulating a button press on parent window */

Callers

nothing calls this directly

Calls 13

OnEditboxChangedMethod · 0.95
UpdateOskStateMethod · 0.95
IsValidCharFunction · 0.85
HasBitFunction · 0.85
ToggleBitFunction · 0.85
InsertCharMethod · 0.80
DeleteCharMethod · 0.80
MovePosMethod · 0.80
SetDirtyMethod · 0.45
InvalidateDataMethod · 0.45
GetTextMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected