Not now. Buttons are still pretty unreliable in shoes, especially on Windows. You can work around the problem by placing the button in the slot, hiding or showing the slot, but you may find that the button will not hide again once it has been pressed once:
Shoes.app do
para 'This is some text.'
@flow = flow :width => 50, :hidden => true do
button 'a' do |btn|
alert 'Hello, World!'
end
end
button 'toggle' do
@flow.toggle
end
para 'Blah blah blah'
end
, : . , , . .
-, . pesto_button , . , , , ( ?), ..:
class PestoButton < Widget
def initialize (text, opts = {})
@border_color = opts[:border_color] || gray
@border_width = opts[:border_width] || 3
@color = opts[:up_color] || gainsboro
@click_color = opts[:down_color] || @border_color
@width = opts[:width] || 80
@click = block_given? ? Proc.new { yield } : nil
@text = text
@visible = true
@flow = flow :width => @width do
background @color
border @border_color, :strokewidth => @border_width
para @text, :align => 'center'
end
@flow.click do
@flow.clear
@flow.append do
background @click_color
border @border_color, :strokewidth => @border_width
para @text, :align => 'center'
end
end
@flow.release do
@flow.clear
@flow.append do
background @color
border @border_color, :strokewidth => @border_width
para @text, :align => 'center'
@click.call if @click
end
end
end
def click
@click = block_given? ? Proc.new { yield } : nil
end
def show
@flow.show
end
def toggle
@flow.toggle
end
def hide
@flow.hide
end
end
Shoes.app do
para 'This is some text.'
@btn = pesto_button 'Click me!' do
alert 'Hello, World!'
end
button 'toggle' do
@btn.toggle
end
button 'new block' do
@btn.click do
alert 'Goodbye, World!'
end
end
button 'no block' do
@btn.click
end
para 'Blah blah blah'
end