button capture with shapes, images on click event #240

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

Comments

Projects
None yet
3 participants
@passenger94
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@dredknight

dredknight Jun 22, 2016

Contributor

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

Contributor

dredknight commented Jun 22, 2016

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

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Sep 7, 2016

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Sep 7, 2016

Contributor

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.

Contributor

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

mostly #264 with insight into #240
* 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

for #240, return the btn, t, l as documented for click, release
* allows buttons > 1
* affects widgets: canvas, plot, svg, textblock, image, shape
* see bugs/bug240.rb
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Sep 8, 2016

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Sep 8, 2016

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jan 21, 2017

Contributor

Closed in Shoes 3.3.2

Contributor

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