mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-29 07:54:40 +00:00
Split ImGuiKey_MouseWheelX into two keys for Plus and Minus #9583
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#9583
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
1.93.0 WIP (19297) Docking
Back-ends:
Custom
Compiler, OS:
clang_version=17.0.0 (clang-1700.6.3.2)
Full config/build information:
// (Copy from the next line. Keep the ``` markers for formatting.)
Details:
We have a command system where commands will execute some code. It's a typical CanExecute() Execute() class. A command is hooked up to an Action which holds an ImGuiKeyChord. When the shortcut is pressed we call the Execute function. I want to create a keyChord using the mouse wheel
Control+MouseWheel+to "SelectParentEntities" andControl+MouseWheel-to "UndoSelectParents".The issue is that we can't properly map those actions without writing special code. Is there any way we can treat the scroll direction as a key press?
I assume this is somewhat easy on windows. On a mac with a trackpad it might be hard as there is so much resolution.
FYI using
GetKeyData(ImGuiKey_MouseWheelX)->AnalogValueyou can access the value/sign information already.Could your code/interface to map actions read the sign of this when mapping selected keys, and check it when polling after e..g the
Shortcut()call.Or does that count as the writing special code you would want to avoid?
Kind of. Here is some of the code so you that have more context on the systems we have.
Here is how we register actions. This registration allows the user to change the keybindings associated with this action. Actions can have two shortcuts similar to VSCode.
Here is how we create our Commands
These commands are added to a CommandList. The command list is executed at a very specific place in the UI where these should execute.
For each command in the CommandList we run this code:
Looks like you could add an extra parameter to
EditorAction, and then store the sign in that structure and add an additional check in theActionShortcut()function?Or as a trick/helper, declare dummy large value for
ImGuiKey_MouseWheelY_PositiveandImGuiKey_MouseWheelY_Negativeand translate them toImGuiKey_MouseWheelY+ stored sign inEditorAction?Seems like either would solve your problem with <10 lines of code. The later has the advantage hiding the extra param from the
EditorAction()constructor, since it's so rarely used.The joystick enums works the way you wanted already, so arguably it is a bit inconsistent that MouseWheel don't, but I found that MouseWheel value was frequently easier to use as a single signed value. Adding two extra enums for each of them would technically be consistent, albeit only confuse code that does a full range scan. I could do that as well.
My worry about adding separate enums values for those is figuring of the key ownership would propagate, e.g. if some code takes ownership of
MouseWheelYit should apply toMouseWheelY_Positiveas well (but not necessarily the opposite).I will experiment with this later, in order to figure out if it can be implemented without problems.