Skip to content
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

button capture with shapes, images on click event #240

Closed
passenger94 opened this issue Apr 10, 2016 · 6 comments
Closed

button capture with shapes, images on click event #240

passenger94 opened this issue Apr 10, 2016 · 6 comments
Labels
Milestone

Comments

@passenger94
Copy link
Contributor

@passenger94 passenger94 commented Apr 10, 2016

i noticed that you can only capture the left mouse button when working with the click event on shapes, image looks the same, maybe other elements.
Looks easy to fix (tried, it works (linux), just commenting if (button == 1) here
https://github.com/Shoes3/shoes3/blob/master/shoes/ruby.c#L1090

But there must be a reason for that, any clues ?

Shoes.app width: 700 do
    shp = oval 25, 25, 100, fill: red
    shp.click do
        b,l,t = mouse
        info "button : #{b}\nleft : #{l}\ntop : #{l}"
    end
    Shoes.show_log
end

no more luck when trying from "outside"

Shoes.app width: 700 do
    shp = oval 25, 25, 100, fill: red
    shp.click do
        b,l,t = input
        info "button : #{b}\nleft : #{l}\ntop : #{l}"
    end
    def input; mouse end
    Shoes.show_log
end
@dredknight
Copy link
Contributor

@dredknight dredknight commented Jun 22, 2016

It seems I am not the only one with this issue. Just stumbled on it today.

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Sep 7, 2016

I've came across something else in this area , not all widgets supply the documented |btn ,t ,l| some just pass in self. You may get better luck with release instead of click.

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Sep 7, 2016

I should describe what I think is happening in canvas.c (shoes_canvas_send_click) it calls shoes_canvas_send_click2(self, button, x, y, &clicked) which calls the widget specific shoes_XXXX_send_click function and and if that return is not nil, then it invokes the callback to user's click passing only self - no btn, no left, no top. Click doe not behave as documented

If I understand the code correctly, click is more like a mouse_down and release would be better named as 'clicked'. I 'm going to try defining the 'clicked` method in ruby.c to be the same C code as release.

Update: I discovered it's not that simple. Ain't that pretty at all.

ccoupe added a commit that referenced this issue Sep 7, 2016
* get release proc working as documented
* release handles multiple buttons. left is 1, wheel click is 2, right
  button is 3 ON LINUX.
* click proc returns self even though the documentation says otherwise.
  BIG deal for backward compatility.
* still on branch graph
@ccoupe ccoupe added the Normal label Sep 8, 2016
@ccoupe ccoupe added this to the 3.3.2 milestone Sep 8, 2016
ccoupe added a commit that referenced this issue Sep 8, 2016
* allows buttons > 1
* affects widgets: canvas, plot, svg, textblock, image, shape
* see bugs/bug240.rb
@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Sep 8, 2016

If anyone knows how to attach click and release procs to a textblock (fragment) please speak up. I suspect this involved with link which changed from Shoes 2 to Shoes 3 after _why left.

@passenger94
Copy link
Contributor Author

@passenger94 passenger94 commented Sep 8, 2016

do you speak about something like :
para "some text ", link( "some interesting text", click: proc{ |thelink| puts "--> #{thelink.inspect}" }), " some other text"

@ccoupe
Copy link
Contributor

@ccoupe ccoupe commented Jan 21, 2017

Closed in Shoes 3.3.2

@ccoupe ccoupe closed this Jan 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants