Open passenger94 opened 9 years ago
Check this out. Try it out with the stack and then try the image. Stack behaves a bit better but eventually both suck big time. Why is this happening ? The drawing tool misbehaves big time?
Shoes.app(width: 1000, height: 1000, resizable: false ) do
@q = stack left: 50, top: 50, width: 100, height: 100 do
border black
end
#@q = image "#{DIR}/static/shoes-icon.png", left: 200, top: 200, width: 50
button "Put some shoes ON" do
@q.attach = Shoes::Mouse
end
end
Something seems wrong. There are times where it seems to detach from the mouse, then moving over the button again and it magically reattach. A little update on your sample to have the cursor centered to the rect.
Shoes.app(width: 1000, height: 1000, resizable: false ) do
@q = stack left: 50, top: 50, width: 100, height: 100 do
border black
end
#@q = image "#{DIR}/static/shoes-icon.png", left: 200, top: 200, width: 50
button "Put some shoes ON" do
@q.left = -@q.width / 2
@q.top = -@q.height / 2
@q.attach = Shoes::Mouse
end
end
Thanks! I played a bit more with it and got some more info. Test 1 - the attach button (with the method) and the element being attached are in the same layer.
Shoes.app(width: 1000, height: 1000, resizable: false ) do
flow left: 200, top: 200, width: 500, height: 500 do
border green, stroke: 5
@q = stack(left: 50, top: 50, width: 100, height: 100) { border black }
button "Put some shoes ON", left: 50, top: 50 do
@q.left = -@q.width / 2
@q.top = -@q.height / 2
@q.attach = Shoes::Mouse
end
end
end
Test 2 - the attach button (with the method) and the element being attached are in different layers.
Shoes.app(width: 1000, height: 1000, resizable: false ) do
flow left: 200, top: 200, width: 500, height: 500 do
border green
@q = stack(left: 50, top: 50, width: 100, height: 100) { border black }
end
button "Put some shoes ON", left: 50, top: 50 do
@q.left = -@q.width / 2
@q.top = -@q.height / 2
@q.attach = Shoes::Mouse
end
end
Observe how the the attachment breaks at TEST 1 when the mouse leaves the layer (green border). In TEST2 the mouse is outside the layer when attach method is initiated so nothing happens. I believe the way Shoes handle layers is the issue but someone who has access to the C++ underworks can see if it is bug or architecture disadvantage.
You stumbled onto something that not many had adventure. HacketyHack doesn't even use it. Perhaps older version had implemented it better but it did not age well.
Shoes is written in C, not C++. shoes_place_decide
is where the action is. The geometry is rather complicated and unlikely to be correct in the case of REL_CURSOR
.
The good news is that your examples are helpful. You should try to attach a button directly to the mouse. This feature is clearly broken.
Ah ok. So do we depricate this one as it is impossible to fix? What you do in #314 is way better for attaching objects to mouse.
Not impossible to fix but it needs some work. This issue should remain open for now. And you could move on something else in the meantime.
What you do in #314 is way better for attaching objects to mouse.
It works really well. Perhaps a basic sample code based on this would be good. Perhaps your wheel with image as a sample (simplified), say displaying clickable static/shoes-icon*.png
, if you are interested. Or sample code for Chipmunk. We can pursue this conversation in #317 .
Will do. Though I will be away till the end of the week.
Have a safe trip @dredknight. Enjoy life!
don't know what was/is the purpose of it ... kinda works but ...