mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 13:37:00 +00:00
Demo: Consoles: Added "Copy" button to demonstrate LogToClipboard
This commit is contained in:
parent
08265bfbd9
commit
5eef7dd82f
@ -2308,6 +2308,7 @@ struct ExampleAppConsole
|
|||||||
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("Add Dummy Error")) AddLog("[error] something went wrong"); ImGui::SameLine();
|
if (ImGui::SmallButton("Add Dummy Error")) AddLog("[error] something went wrong"); ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("Clear")) ClearLog(); ImGui::SameLine();
|
if (ImGui::SmallButton("Clear")) ClearLog(); ImGui::SameLine();
|
||||||
|
bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
|
if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
|
||||||
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
|
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
|
||||||
|
|
||||||
@ -2338,6 +2339,8 @@ struct ExampleAppConsole
|
|||||||
// and appending newly elements as they are inserted. This is left as a task to the user until we can manage to improve this example code!
|
// and appending newly elements as they are inserted. This is left as a task to the user until we can manage to improve this example code!
|
||||||
// If your items are of variable size you may want to implement code similar to what ImGuiListClipper does. Or split your data into fixed height items to allow random-seeking into your list.
|
// If your items are of variable size you may want to implement code similar to what ImGuiListClipper does. Or split your data into fixed height items to allow random-seeking into your list.
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing
|
||||||
|
if (copy_to_clipboard)
|
||||||
|
ImGui::LogToClipboard();
|
||||||
for (int i = 0; i < Items.Size; i++)
|
for (int i = 0; i < Items.Size; i++)
|
||||||
{
|
{
|
||||||
const char* item = Items[i];
|
const char* item = Items[i];
|
||||||
@ -2350,6 +2353,8 @@ struct ExampleAppConsole
|
|||||||
ImGui::TextUnformatted(item);
|
ImGui::TextUnformatted(item);
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
}
|
}
|
||||||
|
if (copy_to_clipboard)
|
||||||
|
ImGui::LogFinish();
|
||||||
if (ScrollToBottom)
|
if (ScrollToBottom)
|
||||||
ImGui::SetScrollHere();
|
ImGui::SetScrollHere();
|
||||||
ScrollToBottom = false;
|
ScrollToBottom = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user