mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 21:09:01 +08:00
Tooltips: made using SetItemTooltip()/IsItemHovered(ImGuiHoveredFlags_ForTooltip) defaults to activate tooltips on disabled items.. (#1485)
This commit is contained in:
parent
6eb2681c09
commit
9714594c35
@ -53,6 +53,9 @@ Breaking changes:
|
||||
|
||||
Other changes:
|
||||
|
||||
- Tooltips: made using SetItemTooltip()/IsItemHovered(ImGuiHoveredFlags_ForTooltip) defaults to
|
||||
activate tooltips on disabled items. This is done by adding ImGuiHoveredFlags_AllowWhenDisabled
|
||||
to the default value of style.HoverFlagsForTooltipMouse/HoverFlagsForTooltipNav. (##1485)
|
||||
- Nav: Tabbing always enable nav highlight when ImGuiConfigFlags_NavEnableKeyboard is set.
|
||||
Previously was inconsistent and only enabled when stepping through a non-input item.
|
||||
(#6802, #3092, #5759, #787)
|
||||
|
@ -1200,8 +1200,8 @@ ImGuiStyle::ImGuiStyle()
|
||||
HoverStationaryDelay = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
||||
HoverDelayShort = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayShort). Usually used along with HoverStationaryDelay.
|
||||
HoverDelayNormal = 0.40f; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayNormal). "
|
||||
HoverFlagsForTooltipMouse = ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort; // Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using mouse.
|
||||
HoverFlagsForTooltipNav = ImGuiHoveredFlags_NoSharedDelay | ImGuiHoveredFlags_DelayNormal; // Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using keyboard/gamepad.
|
||||
HoverFlagsForTooltipMouse = ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_AllowWhenDisabled; // Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using mouse.
|
||||
HoverFlagsForTooltipNav = ImGuiHoveredFlags_NoSharedDelay | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_AllowWhenDisabled; // Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using keyboard/gamepad.
|
||||
|
||||
// Default theme
|
||||
ImGui::StyleColorsDark(this);
|
||||
|
@ -828,13 +828,18 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
ImGui::SeparatorText("Custom");
|
||||
|
||||
HelpMarker(
|
||||
"Passing ImGuiHoveredFlags_ForTooltip to IsItemHovered() is the preferred way to standardize"
|
||||
"tooltip activation details across your application. You may however decide to use custom"
|
||||
"flags for a specific tooltip instance.");
|
||||
|
||||
// The following examples are passed for documentation purpose but may not be useful to most users.
|
||||
// Passing ImGuiHoveredFlags_Tooltip to IsItemHovered() will pull ImGuiHoveredFlags flags values from
|
||||
// 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' depending on whether mouse or gamepad/keyboard is being used.
|
||||
// With default settings, ImGuiHoveredFlags_Tooltip is equivalent to ImGuiHoveredFlags_DelayShort + ImGuiHoveredFlags_Stationary.
|
||||
ImGui::Button("Manual", sz);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip))
|
||||
ImGui::SetTooltip("I am a manually emitted tooltip");
|
||||
ImGui::SetTooltip("I am a manually emitted tooltip.");
|
||||
|
||||
ImGui::Button("DelayNone", sz);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNone))
|
||||
@ -846,12 +851,21 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
ImGui::Button("DelayLong", sz);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay))
|
||||
ImGui::SetTooltip("I am a tooltip with a long delay (%0.2f sec)", ImGui::GetStyle().HoverDelayNormal);
|
||||
ImGui::SetTooltip("I am a tooltip with a long delay (%0.2f sec).", ImGui::GetStyle().HoverDelayNormal);
|
||||
|
||||
ImGui::Button("Stationary", sz);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
ImGui::SetTooltip("I am a tooltip requiring mouse to be stationary before activating.");
|
||||
|
||||
// Using ImGuiHoveredFlags_ForTooltip will pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav',
|
||||
// which default value include the ImGuiHoveredFlags_AllowWhenDisabled flag.
|
||||
// As a result, Set
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::Button("Disabled item", sz);
|
||||
ImGui::EndDisabled();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip))
|
||||
ImGui::SetTooltip("I am a a tooltip for a disabled item.");
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user