Shoes button double and right clicks
- From:
- J. Kaiden
- Date:
- 2011-06-16 @ 00:35
hey folks,
wondering about capturing mouse double-clicks and right-clicks with shoes.
i googled myself silly, and searched up, down and inside-out on this list,
but didn't find anything, so here goes...
i can do this to capture quick double clicks, and it *mostly* works, but
it seems ridiculous...
###
Shoes.app do
btn = button("double-click me!"){|btn|
time = Time.now.to_i / 100.00
btn.click{
newtime = Time.now.to_i / 100.00
dif = newtime - time
if dif < 0.009
p "double-clicked"
time = Time.now.to_i / 100.00
else
time = Time.now.to_i / 100.00
end
}
}
end
###
... and right clicks are completely beyond me (i'm a hobbyist hack at
best...) so - is there an easy way to capture double and right clicks that
i'm missing? when i look at btn.methods, i see pretty much the same i see
for everything... am i missing something terribly obvious? is there a way
to see what's going on with the mouse like there is with a key-press?:
# sample21.rb
Shoes.app :width => 250, :height => 40 do
@info = para 'NO KEY is PRESSED.'
keypress{|key| @info.text = "#{key.inspect} was PRESSED."}
end
# (thanks ashbb for the turorial-note http://shoes-tutorial-note.heroku.com/
)
the block variable to the #click method is (as far as i can tell) the
button itself, is there somewhere in the shoes source (my knees are shaking
just thinking of it) that i should take a look to see if i can pick up
double and right-clicks?
any ideas greatly appreciated,
-j
Re: [shoes] Shoes button double and right clicks
- From:
- ashbb
- Date:
- 2011-06-16 @ 10:47
Hi Jake,
Sorry, Shoes button elements can only recognize a-left-mouse-click.
So, please create your own button. ;-)
For example, how about the following?
# left/right click
# Look at this: http://shoes.heroku.com/manual/App.html#mouse
Shoes.app do
my_button = stack width: 200 do
background yellow, curve: 10
para 'left or right click me', align: 'center'
end
my_button.click do
alert "clicked: #{mouse.first}"
end
end
# double click
Shoes.app do
my_button = stack width: 150 do
background yellow, curve: 10
para 'double click me', align: 'center'
end
_t = t = 0
my_button.click do
t = Time.now.to_i
alert 'double clicked' if _t == t
_t = t
end
end
Enjoy,
ashbb
Re: [shoes] Shoes button double and right clicks
- From:
- J. Kaiden
- Date:
- 2011-06-16 @ 13:45
ashbb-
the #mouse method was just what i was looking for! i managed to miss it
in the manual... thanks again!
cheers,
- j