JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Languages on JVM » JRuby  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 [問題]rubygame滑鼠事件
mosluce





發文: 1
積分: 0
於 2008-02-20 12:46 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  class MouseDownEvent < Event
    attr_accessor :string,:pos,:button
    def initialize(pos,button)
      @pos = pos
      if button.kind_of? Integer
        @button = button
        @string = Rubygame::Mouse::MOUSE2STR[button] #a string or nil
      elsif key.kind_of? String
        @button = Rubygame::Mouse::STR2MOUSE[key]
        if @button != nil
          @string = button
        else
          raise(ArgumentError,"First argument of MouseDownEvent.new() must be an Integer Mouse button indentifier (like MOUSE_LEFT) or a String (like \"left\"). Got %s (%s)"%[button,button.class])
        end
      end
    end
  end


裡面的pos是做什麼用的?只有看到引入沒有看到操作...
另外要判斷滑鼠點的按鍵是哪個、在哪個位置點也是使用這個Class嗎?

下面是他的說明:
  # Indicates that a mouse button was pressed.
  #
  # This event has these attributes:
  # string:: string indicating the button that was pressed ("left","middle", or
  # "right").
  # pos:: the position of the mouse cursor when the button was pressed,
  # in the form [x,y].
  # button:: the mouse button that was pressed; one of these constants in
  # module Rubygame (or the corresponding button number):
  # MOUSE_LEFT:: 1; left mouse button
  # MOUSE_MIDDLE:: 2; middle mouse button
  # MOUSE_RIGHT:: 3; right mouse button


reply to postreply to post
作者 Re:[問題]rubygame滑鼠事件 [Re:mosluce]
koji

秒速5センチメートル

站長

發文: 8415
積分: 19
於 2008-02-20 17:50 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
pos:: the position of the mouse cursor when the button was pressed

不就是你要的?

koji


reply to postreply to post
JCConf Taiwan 2015 開始售票了!!
Facebook上的TWJUG社團,歡迎加入
» JWorld@TW »  Languages on JVM » JRuby

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8