-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Altering Drag/Sliders behaviors / Question: enable imgui io event handling only for specific elements #8223
Comments
I'm afraid I am struggling to understand what any of this means. |
I don't think this will work for us. If we handle left click ourselves for certain elements, but want imgui to handle left click when a text field is edited, how should this be done? As soon as an event is submitted, imgui will handle all responses to that event, right? |
I think for us the ideal scenario would be to enable io event handling of imgui only for certain elements and then check if the event caused a change in the UI / was handled by imgui. If imgui did not handle the event (e.g. when the user does not hover anything), we try to handle it with our own management. This would allow us to define default actions that imgui performs. But for this I need to be able to tell imgui for what elements to handle io events, either by calling a function before such an element is rendered or in a configuration. With the solution of submitting or not submitting an entire IOEvent I see following issue / uncertainty: if I want to handle left click on buttons with my own code, I would need to not submit left click at all. But if I want imgui to still handle left click for Text elements, submitting the event could cause a button to still react to the event. |
I'm still really confused by your use case. Are you sure it isn't just a case of you not using etc |
filtering entire IOEvents with io.WantCaptureMouse would lead to all imgui elements not receiving them, right? However, this is not what I need, as I might need some elements to still receive them. In general I am wondering how flexible ImGui is with adding own custom user interaction logic to the ImGui elements and changing the pre-existing interaction logic of ImGui. If it is still to vague and abstract I would probably close this for now and come back with more concrete problems in the future. |
I don't understand what this mean in concrete terms. Could you clarify? What does "handle dragging a dragFloat in my application" means? |
With dragging I mean the process of moving the mouse while pressing a mouse button. |
Well that's exactly the point and purpose of a DragFloat(). What precisely don't you like about it? Presently your whole question seems like a bizarre twisted workaround for a XY Problem where you still haven't explained the actual underlying reason. We are still unpealing unneeded layers in your problem statement. |
e.g. that sentence in the first message is a concrete request. In your own source file you can create a wrapper: bool ImGui::DragFloatCustom(label, ....)
{
float in_value = value;
bool ret = ImGui::DragFloat(label, ....);
if (IsItemActivated())
g_DragFloatCustomData->InitialValue = in_value; // Store in your data structure
if (IsItemActive() && IsMouseClicked(ImGuiMouse_Right))
{
value = g_DragFloatCustomData->InitialValue;
ret = true;
ImGui::ClearActiveID();
}
return true;
} |
For now preventing ImGuis dragging is what I need and an example case where I need to override the default user interaction logic of ImGui. I am not saying that there is something wrong with ImGui's dragging or that I don't want a DragFloat to be dragged.
Do you mean changing the source code or working with the API? The latter would be preferred as we are working in Java and changing the original source would create more build steps. |
Alright so your problem has nothing to do with IO Event Handling or Inputs. You want to create custom widgets behavior. You shouldn't change imgui source code. You can work with the API but to create custom widgets it's often easier if you use imgui_internal.h, as the code snippets above.
Code in previous post.
The "selection" is entirely a concept that you control and you own. You are free to decide you want to start writing back to more of your items.
There are /100 (Alt) and *10 (Shift) factors currently hardcoded at the lowest-level |
…modifiers altering the tweak speed. (#8223)
Thanks for the info and sorry for the XY Problem. A new flag would probably be beneficial. |
I have pushed two changes: 4ad5496 added float speed = 1.0f;
if (your_own_logic)
speed = 42.0f;
ImGui::DragFloat(...., speed, ...., ImGuiSliderFlags_NoSpeedTweaks); 8237ab4 which stores initial slider/drag value on activation, as an (undocumented) helper to facilitate implementing (1). It becomes: bool ImGui::DragFloatCustom(label, ....)
{
float in_value = value;
bool ret = ImGui::DragFloat(label, ....);
if (IsItemActive() && IsMouseClicked(ImGuiMouse_Right))
{
ret |= memcmp(&value, g.ActiveIdValueOnActivation, sizeof(value));
memcpy(&value, g.ActiveIdValueOnActivation, sizeof(value));
ImGui::ClearActiveID();
}
return ret;
} Now I should be honest: For example, we should Ctrl+Click to input text into a Drag or Slider. To clarify, normally the way to do that would be to write new widgets. But if you have not familiar with the lib and not consuming it from C++ it's going to be harder for you. |
…modifiers altering the tweak speed. (ocornut#8223)
Version/Branch of Dear ImGui:
Version 1.91.6, Branch: master
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Windows 11
Full config/build information:
No response
Details:
My question is about how flexible imgui is with handling IO events with own code and disabling them in imgui so our own app has full control.
Let's start with the app situation: I am creating an app where every action a user performs is encapsulated in an "operator". These are registered to IO Events and managed in our application. These operators range from complex actions where a user presses a hotkey and modifies the database. Example: User presses G and moves an object in the viewport, while moving they can press other keys to influence the operator e.g. only move on X Axis.
Operators can also be very simple basic UI interactions like dragging a float slider. We need this as we have more complex management of these kinds of actions, for example pressing right click while dragging a slider aborts the dragging and reverts changes. We also want full control over what key is responsible for changing the increment of updating a slider.
It's an important aspect of our design architecture that user actions / io events are kept outside of the UI rendering, so the UI layer is mostly responsible only for defining what is drawn and how it is drawn.
However, I don't want to do an operator for every UI action, especially text editing, as setting the cursor in a text field is probably better and more efficiently done in imgui.
So the question is: can I disable imguis handling of IO Events for all elements and reactivate it only in certain conditions / elements rendered? E.g. for text elements I'd like to always let imgui handle it. For sliders I'd like to only let imgui handle it when I click on it to enter text and not drag it.
The text was updated successfully, but these errors were encountered: