MCPcopy Create free account
hub / github.com/MyGUI/mygui / notifyButtonPressed

Method notifyButtonPressed

Demos/Demo_Console/Console.cpp:94–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94 void Console::notifyButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
95 {
96 MyGUI::EditBox* edit = _sender->castType<MyGUI::EditBox>();
97 size_t len = edit->getCaption().length();
98 if ((_key == MyGUI::KeyCode::Backspace) && (len > 0) && (mAutocomleted))
99 {
100 edit->deleteTextSelection();
101 len = edit->getCaption().length();
102 edit->eraseText(len - 1);
103 }
104
105 MyGUI::UString command = edit->getCaption();
106 if (command.length() == 0)
107 return;
108
109 for (auto& delegate : mDelegates)
110 {
111 if (delegate.first.find(command) == 0)
112 {
113 if (command == delegate.first)
114 break;
115 edit->setCaption(delegate.first);
116 edit->setTextSelection(command.length(), delegate.first.length());
117 mAutocomleted = true;
118 return;
119 }
120 }
121 mAutocomleted = false;
122 }
123
124 void Console::addToConsole(const MyGUI::UString& _line)
125 {

Callers

nothing calls this directly

Calls 6

deleteTextSelectionMethod · 0.80
eraseTextMethod · 0.80
lengthMethod · 0.45
findMethod · 0.45
setCaptionMethod · 0.45
setTextSelectionMethod · 0.45

Tested by

no test coverage detected