RunicVTT
Open Source Virtual Tabletop for TTRPG using P2P
Loading...
Searching...
No Matches
UiTypingGuard.h
Go to the documentation of this file.
1
// UiTypingGuard.h
2
#pragma once
3
#include <imgui.h>
4
5
namespace
UiTypingGuard
6
{
7
// single flag for your whole app
8
inline
bool
g_isTyping
=
false
;
9
10
// call this *right after* each InputText you care about
11
inline
void
TrackThisInput
()
12
{
13
// true while the last item (the input) is active
14
if
(ImGui::IsItemActive())
15
g_isTyping
=
true
;
16
else
if
(!ImGui::IsAnyItemActive())
17
g_isTyping
=
false
;
// automatic clear when nothing is active
18
}
19
20
inline
bool
IsTyping
()
21
{
22
return
g_isTyping
;
23
}
24
25
// optional: hard reset per-frame before your UI begins
26
inline
void
FrameReset
()
27
{
28
if
(!ImGui::IsAnyItemActive())
29
g_isTyping
=
false
;
30
}
31
}
// namespace UiTypingGuard
UiTypingGuard
Definition
UiTypingGuard.h:6
UiTypingGuard::FrameReset
void FrameReset()
Definition
UiTypingGuard.h:26
UiTypingGuard::TrackThisInput
void TrackThisInput()
Definition
UiTypingGuard.h:11
UiTypingGuard::g_isTyping
bool g_isTyping
Definition
UiTypingGuard.h:8
UiTypingGuard::IsTyping
bool IsTyping()
Definition
UiTypingGuard.h:20
include
UiTypingGuard.h
Generated by
1.10.0