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

Method OnClick

src/newgrf_gui.cpp:2085–2109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2083 }
2084
2085 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
2086 {
2087 switch (widget) {
2088 case WID_SVP_PRESET_LIST: {
2089 auto it = this->vscroll->GetScrolledItemFromWidget(this->presets, pt.y, this, WID_SVP_PRESET_LIST);
2090 if (it != this->presets.end()) {
2091 this->selected = it - this->presets.begin();
2092 this->presetname_editbox.text.Assign(*it);
2093 this->SetWidgetDirty(WID_SVP_PRESET_LIST);
2094 this->SetWidgetDirty(WID_SVP_EDITBOX);
2095 }
2096 break;
2097 }
2098
2099 case WID_SVP_SAVE: {
2100 Window *w = FindWindowById(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
2101 if (w != nullptr) {
2102 auto text = this->presetname_editbox.text.GetText();
2103 if (!text.empty()) w->OnQueryTextFinished(std::string{text});
2104 }
2105 this->Close();
2106 break;
2107 }
2108 }
2109 }
2110
2111 void OnResize() override
2112 {

Callers

nothing calls this directly

Calls 10

FindWindowByIdFunction · 0.85
SetWidgetDirtyMethod · 0.80
endMethod · 0.45
beginMethod · 0.45
AssignMethod · 0.45
GetTextMethod · 0.45
emptyMethod · 0.45
OnQueryTextFinishedMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected