MCPcopy Create free account
hub / github.com/crosire/reshade / key_input_box

Method key_input_box

source/imgui_widgets.cpp:249–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249bool reshade::imgui::key_input_box(const char *name, unsigned int key[4], const reshade::input &input)
250{
251 bool res = false;
252
253 char buf[48]; buf[0] = '\0';
254 if (key[0] || key[1] || key[2] || key[3])
255 buf[input::key_name(key).copy(buf, sizeof(buf) - 1)] = '\0';
256
257 ImGui::BeginDisabled(ImGui::GetCurrentContext()->NavInputSource == ImGuiInputSource_Gamepad);
258
259 ImGui::InputTextWithHint(name, _("Click to set keyboard shortcut"), buf, sizeof(buf), ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_NoUndoRedo | ImGuiInputTextFlags_NoHorizontalScroll);
260
261 if (ImGui::IsItemActive())
262 {
263 const unsigned int last_key_pressed = input.last_key_pressed();
264 if (last_key_pressed != 0)
265 {
266 if (last_key_pressed == 0x08) // Backspace
267 {
268 key[0] = 0;
269 key[1] = 0;
270 key[2] = 0;
271 key[3] = 0;
272 }
273 else if (last_key_pressed < 0x10 || last_key_pressed > 0x12) // Exclude modifier keys
274 {
275 key[0] = last_key_pressed;
276 key[1] = input.is_key_down(0x11); // Ctrl
277 key[2] = input.is_key_down(0x10); // Shift
278 key[3] = input.is_key_down(0x12); // Alt
279 }
280
281 res = true;
282 }
283 }
284 else if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip))
285 {
286 ImGui::SetTooltip(_("Click in the field and press any key to change the shortcut to that key or press backspace to remove the shortcut."));
287 }
288
289 ImGui::EndDisabled();
290
291 return res;
292}
293
294bool reshade::imgui::font_input_box(const char *name, const char *hint, std::filesystem::path &path, std::filesystem::path &dialog_path, float &size)
295{

Callers

nothing calls this directly

Calls 8

BeginDisabledFunction · 0.85
InputTextWithHintFunction · 0.85
IsItemActiveFunction · 0.85
IsItemHoveredFunction · 0.85
SetTooltipFunction · 0.85
EndDisabledFunction · 0.85
last_key_pressedMethod · 0.45
is_key_downMethod · 0.45

Tested by

no test coverage detected