|
@@ -1244,8 +1244,8 @@ ImGuiIO::ImGuiIO()
|
|
|
// FIXME: Should in theory be called "AddCharacterEvent()" to be consistent with new API
|
|
|
void ImGuiIO::AddInputCharacter(unsigned int c)
|
|
|
{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
|
|
+ IM_ASSERT(Ctx != NULL);
|
|
|
+ ImGuiContext& g = *Ctx;
|
|
|
if (c == 0 || !AppAcceptingEvents)
|
|
|
return;
|
|
|
|
|
@@ -1357,10 +1357,10 @@ static ImGuiInputEvent* FindLatestInputEvent(ImGuiInputEventType type, int arg =
|
|
|
void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
|
|
{
|
|
|
//if (e->Down) { IMGUI_DEBUG_LOG_IO("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
|
|
|
+ IM_ASSERT(Ctx != NULL);
|
|
|
if (key == ImGuiKey_None || !AppAcceptingEvents)
|
|
|
return;
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
|
|
+ ImGuiContext& g = *Ctx;
|
|
|
IM_ASSERT(ImGui::IsNamedKeyOrModKey(key)); // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API.
|
|
|
IM_ASSERT(!ImGui::IsAliasKey(key)); // Backend cannot submit ImGuiKey_MouseXXX values they are automatically inferred from AddMouseXXX() events.
|
|
|
IM_ASSERT(key != ImGuiMod_Shortcut); // We could easily support the translation here but it seems saner to not accept it (TestEngine perform a translation itself)
|
|
@@ -1435,8 +1435,8 @@ void ImGuiIO::SetAppAcceptingEvents(bool accepting_events)
|
|
|
// Queue a mouse move event
|
|
|
void ImGuiIO::AddMousePosEvent(float x, float y)
|
|
|
{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
|
|
+ IM_ASSERT(Ctx != NULL);
|
|
|
+ ImGuiContext& g = *Ctx;
|
|
|
if (!AppAcceptingEvents)
|
|
|
return;
|
|
|
|
|
@@ -1459,8 +1459,8 @@ void ImGuiIO::AddMousePosEvent(float x, float y)
|
|
|
|
|
|
void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
|
|
{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
|
|
+ IM_ASSERT(Ctx != NULL);
|
|
|
+ ImGuiContext& g = *Ctx;
|
|
|
IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
|
|
|
if (!AppAcceptingEvents)
|
|
|
return;
|
|
@@ -1482,8 +1482,8 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
|
|
// Queue a mouse wheel event (some mouse/API may only have a Y component)
|
|
|
void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
|
|
|
{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
|
|
+ IM_ASSERT(Ctx != NULL);
|
|
|
+ ImGuiContext& g = *Ctx;
|
|
|
|
|
|
// Filter duplicate (unlike most events, wheel values are relative and easy to filter)
|
|
|
if (!AppAcceptingEvents || (wheel_x == 0.0f && wheel_y == 0.0f))
|
|
@@ -1499,8 +1499,8 @@ void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
|
|
|
|
|
|
void ImGuiIO::AddFocusEvent(bool focused)
|
|
|
{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
|
|
+ IM_ASSERT(Ctx != NULL);
|
|
|
+ ImGuiContext& g = *Ctx;
|
|
|
|
|
|
// Filter duplicate
|
|
|
const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_Focus);
|