-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Plot functions registering their ID change from 1.67 to 1.68 #3072
Comments
Most likely it is It was previously not registering its it. |
I am not sure to understand. I was drawing several InvisibleButtons (for having control_points) over the PlotLines, so the code posted above was used several times, once for each InvisibleButton. Only one of them was active after mouse click. |
No you won't but you can test the coordinate. |
yes but this changes the logic behind Control_point (which was an independent widget that knows when it is activated) and makes everything less simple.
I have tried this in 1.68 and does not solve the problem. perhaps in later versions? |
I don't know, you can investigate. |
No, it does not work This was the self contained ControlPoint function ControlPoint(ID,graph,pos,r)
r = r or 5
local origin = graph.origin
local size = graph.size
local x,y = pos.x,pos.y
local xpos = size.x*(x - graph.xmin)/(graph.xmax-graph.xmin)
local ypos = size.y*(y - graph.ymin)/(graph.ymax-graph.ymin)
local b_pos = ig.ImVec2(origin.x + xpos - r,origin.y - ypos - r)
ig.SetCursorScreenPos(b_pos)
ig.PushIDStr(ID)
ig.InvisibleButton("pp",ig.ImVec2(r*2, r*2))
local is_active = ig.IsItemActive()
ig.PopID()
local draw_list = ig.GetWindowDrawList()
draw_list:AddCircleFilled(ig.ImVec2(origin.x + xpos,origin.y - ypos), r, ig.U32(1,0,0,1))
if is_active then
local m = ig.GetIO().MousePos
local xval = graph.xmin + (graph.xmax-graph.xmin)*(m.x - origin.x)/size.x
local yval = graph.ymin + (graph.ymax-graph.ymin)*(-m.y + origin.y)/size.y
pos.x = xval
pos.y = yval
end
end where graph is PlotLines plus some info about its size ,position and internal coordinate limits. It is a pitty loosing this behaviour. |
Trying to change the ControlPoint logic I am now using isItemActive just after PlotLines but it never returns true!! ig.IsItemHovered() and ig.IsMouseDown(0) does the trick if ig.IsItemHovered() and ig.IsMouseDown(0) then
local b_pos2 = b_pos + ig.ImVec2(r*2,r*2)
local m = ig.GetIO().MousePos
if m.x > b_pos.x and m.x < b_pos2.x and m.y > b_pos.y and m.y < b_pos2.y then
is_active = true
end
end But if mouse is moved too fast the coordinate test fails. Solved with if ig.IsItemHovered() and ig.IsMouseDown(0) then
local b_pos2 = b_pos + ig.ImVec2(r*2,r*2)
local m = ig.GetIO().MousePos - ig.GetIO().MouseDelta
if m.x > b_pos.x and m.x < b_pos2.x and m.y > b_pos.y and m.y < b_pos2.y then
is_active = true
end
end |
Actually this would have never worked, see #7935 and the fact that I made changes today (since You probably solved this anyhow already, especially since overlap support was improved in 1.89.7. Let me know if this is still relevant for you and if you don't have a satisfying answer for it! |
Hi,
There is some old code that was working on 1.67 but stopped to work in 1.68. Basically I draw a PlotLines widget and then some InvisibleButtons over it. What stopped to work was IsItemActive in this lines of code: Previously is_active was true when clicking over this item but in 1.68 stopped to work.
I looked in docs/CHANGELOG.txt for changes in 1.68 but I was not able to find any reference to IsItemActive. What could it be?
The text was updated successfully, but these errors were encountered: