[wxruby-users] use bitmapButton with mouseEvent?

Pat Kiatchaipipat lists at ruby-forum.com
Sat Apr 19 01:36:01 EDT 2008


hi. I want to make button that can change picture when mouse is entering
and can click to use function. and this is my code.


    @button2 = BitmapButton.new(@window, -1, @picturebox1_bmp,
Point.new(248,89),       Size.new(53, 53))
    @button2.evt_mouse_events{ |event| evtmouse2(event) }
    evt_button(@button2.get_id()) { |event| evtbtn2()}


    def evtmouse2(event)
      if event.entering == true
        @button2.set_bitmap_label(@picturebox2_bmp)
      end
      if event.leaving == true
        @button2.set_bitmap_label(@picturebox1_bmp)
      end
    end


    def evtbtn2()
      #mycode
    end

It work normally when I use mouse enter the button it can change
picture. but when I click on it. it can't use evtbtn2. what I doing
wrong?? I try to use event.left_down to capture when mouse was clicked.
It work but the button show was not pushed. how can I solve it?
-- 
Posted via http://www.ruby-forum.com/.


More information about the wxruby-users mailing list