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

Method ClickEditBox

src/misc_gui.cpp:872–899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

870}
871
872void QueryString::ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed)
873{
874 const NWidgetLeaf *wi = w->GetWidget<NWidgetLeaf>(wid);
875
876 assert((wi->type & WWT_MASK) == WWT_EDITBOX);
877
878 bool rtl = _current_text_dir == TD_RTL;
879 Dimension sprite_size = GetScaledSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT);
880 int clearbtn_width = sprite_size.width + WidgetDimensions::scaled.imgbtn.Horizontal();
881
882 Rect cr = wi->GetCurrentRect().WithWidth(clearbtn_width, !rtl);
883
884 if (IsInsideMM(pt.x, cr.left, cr.right)) {
885 if (!this->text.GetText().empty()) {
886 this->text.DeleteAll();
887 w->HandleButtonClick(wid);
888 w->OnEditboxChanged(wid);
889 }
890 return;
891 }
892
893 if (w->window_class != WC_OSK && _settings_client.gui.osk_activation != OSKA_DISABLED &&
894 (!focus_changed || _settings_client.gui.osk_activation == OSKA_IMMEDIATELY) &&
895 (click_count == 2 || _settings_client.gui.osk_activation != OSKA_DOUBLE_CLICK)) {
896 /* Open the OSK window */
897 ShowOnScreenKeyboard(w, wid);
898 }
899}
900
901/** Class for the string query window. */
902struct QueryStringWindow : public Window

Callers 1

DispatchLeftClickEventFunction · 0.80

Calls 11

GetScaledSpriteSizeFunction · 0.85
IsInsideMMFunction · 0.85
ShowOnScreenKeyboardFunction · 0.85
HorizontalMethod · 0.80
WithWidthMethod · 0.80
GetCurrentRectMethod · 0.80
DeleteAllMethod · 0.80
HandleButtonClickMethod · 0.80
emptyMethod · 0.45
GetTextMethod · 0.45
OnEditboxChangedMethod · 0.45

Tested by

no test coverage detected