View Single Post
Old 08-02-2015, 07:12 AM   #3
Lazarus
Human being with feelings
 
Join Date: Aug 2013
Posts: 1,355
Default

Thanks, but I'm 99% sure It's not the mouse handling, I'm half as sure as that that it's the mouse_cap state not getting through to the script.

Here's a script that's been bodged-up from one of Schwa's tests he posted in the early days...
Code:
gfx.init("Click test",200,200)
reaper.atexit(gfx.quit)

---- generic mouse handling ----

mouse={}

function OnMouseDown()
  reaper.ShowConsoleMsg("OnMouseDown\n")
  mouse.down=true ; mouse.capcnt=0
  mouse.ox,mouse.oy=gfx.mouse_x,gfx.mouse_y
end

function OnMouseDoubleClick()
  reaper.ShowConsoleMsg("OnMouseDoubleClick\n")
end

function OnMouseMove()
   
  mouse.lx,mouse.ly=gfx.mouse_x,gfx.mouse_y
  mouse.capcnt=mouse.capcnt+1
end

function OnMouseUp()
  reaper.ShowConsoleMsg("OnMouseUp\n")
  mouse.down=false
  mouse.uptime=os.clock()
end

---- runloop ----

function runloop()
  gfx.clear=0xFF0000
  
  gfx.r=1
  gfx.rect(0,0,200,200)
  if gfx.mouse_cap&1 == 1 then
    if not mouse.down then
      OnMouseDown()      
      if mouse.uptime and os.clock()-mouse.uptime < 0.25 then 
        OnMouseDoubleClick()
      end
    elseif gfx.mouse_x ~= mouse.lx or gfx.mouse_y ~= mouse.ly then
      OnMouseMove() 
    end
  elseif mouse.down then 
    OnMouseUp() 
  end
  gfx.update() 
  local c=gfx.getchar()
  if c >= 0 and c ~= 27 then reaper.defer(runloop) end
end

reaper.defer(runloop)
If people can run they'll see that although Reaper controls respond correctly to tapping touchpads and touching the screen, the ReaScript code does not.
Lazarus is offline   Reply With Quote