Comments (7)
Now I have this code
if (ImGui::IsItemHovered() && ImGui::GetIO().MouseClicked[1]) {
ImGui::OpenPopupEx("Context menu", false);
Breaking on the second line
when I click the left button the MouseClicked array is [false,true,true,true,true]
when I click the right button the MouseClicked array is [false,true,false, false, false]
I believe the problem is here in line 147 of gui.cpp
// Update for next frame; set to false only if the mouse has been released
engine->mousePressed[i] = !engine->mouseReleased;
The state of buttons that were not pressed is inverted, so they go to true
changing line 147 to
if (engine->mousePressed[i]) engine->mousePressed[i] = !engine->mouseReleased;
fixes it and my original code now works.
I can make a pull request if you like.
from ofximgui.
Assuming you are building a Desktop app here is where we are passing the button info
https://github.com/jvcleave/ofxImGui/blob/master/src/EngineGLFW.cpp#L113
You should then check which button like this
if (ImGui::GetIO().MouseClicked[1])
{
//do something
}
from ofximgui.
I'm building and running on Windows 10.
I can see onMousePressed gets the right click event with button number 2, then translates it to 1 and it sets mousepressed[1] true;
So I need to check button 1 for the right click
But then my code is like this
bool gotInput = (ImGui::InputText("", urlText, 1024, EnterForTrue));
if (ImGui::BeginPopupContextItem("item context menu", 1)) {
(ImGui::Selectable("Copy")) ;
(ImGui::Selectable("Paste")) ;
ImGui::EndPopup();
}
and I get the popup for any mouse button.
Following the thread through, as soon as the field is hovered BeginPopupContextItem calls isMouseClicked which looks at IO.MouseDownDuration.
With no mouse clicks all 5 values are minus 1.
isMouseClicked only returns true if the requested button duration has a value of zero.
I put a break on the true return and then I see
If the left mouse button is clicked, the value for button[0] is a small positive number and all the others are zero so I get a true return for button[1] == 0
If the right mouse button is clicked, the value for button[1] is zero and all the others remain at minus 1 and I also get a true return button[1] == 0
I can see the code setting the MouseDownDurations at lines 2086 to 2089 of ImGui.cpp but I can't see why button 0 should work differently from button 1- maybe timing on when the break happens.
Anyway, I think I will make my own version of BeginPopupContextItem checking just MouseClicked
from ofximgui.
@rjx-ray rjx-ray@81c54a1 seems reasonable. A PR would be appreciated
from ofximgui.
from ofximgui.
no rush here. it seems like a simple tweak if someone needs it in the meantime
as for the clipboard changes that seems to be more complicated so it would probably be best at it's own PR
from ofximgui.
Fixed in current master (1.65 imgui)
from ofximgui.
Related Issues (20)
- No gui on Android HOT 2
- UTF-8 rendering fails with garbled characters. I need your help! Thank you! HOT 2
- input latin characters HOT 2
- ofxImGuiLoggerChannel.h HOT 2
- Merging forks : ImGuiContext and more HOT 8
- EGl window rk boards HOT 10
- ofxImGui upgrade HOT 8
- arb textures HOT 1
- imgui_stdlib.h and imgui_stdlib.cpp should be included in project files HOT 1
- Closing a window within a window? HOT 3
- imgui_impl_glfw_context_support.h missing from develop branch.
- develop brach broken HOT 5
- ofxImGui::Gui::exit() released context, can't Gui::setup() again HOT 2
- OF 0.12 compatibility HOT 1
- Drawing ofFbo's texture as ImGui::Image(); HOT 3
- constexpr float ofColorScale: Syntax error in input HOT 1
- Example Demo will not compile Ubuntu version 24.04 and Openframeworks version 0.12.0 both fresh install HOT 2
- it's possible to use more than one instance of ofxImGui (inside classes) in the same ofApp? HOT 3
- Unknown type name 'ofVec2f'
- I make oF window borderless(not fullscreen),the screen display has an offset(mouse also)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofximgui.