mirror of https://github.com/ocornut/imgui
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 Error")) AddLog("[error] something went wrong"); 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;
|
||||
//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!
|
||||
// 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
|
||||
if (copy_to_clipboard)
|
||||
ImGui::LogToClipboard();
|
||||
for (int i = 0; i < Items.Size; i++)
|
||||
{
|
||||
const char* item = Items[i];
|
||||
|
@ -2350,6 +2353,8 @@ struct ExampleAppConsole
|
|||
ImGui::TextUnformatted(item);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
if (copy_to_clipboard)
|
||||
ImGui::LogFinish();
|
||||
if (ScrollToBottom)
|
||||
ImGui::SetScrollHere();
|
||||
ScrollToBottom = false;
|
||||
|
|
Loading…
Reference in New Issue