Old 08-01-2015, 05:58 PM   #1
Lazarus
Human being with feelings
 
Join Date: Aug 2013
Posts: 1,355
Default ReaScript gfx - mousepad/touch click troubles...

Can somebody confirm that using ReaScript gfx mouse_cap doesn't reliably get the left mouse button down status from mousepad touches or touch screen touches? I'm imagining the messages are too momentary for them to consistently register when the script is called.

If so is there something that can be done to fix this? Ideally full multitouch compatibility and touchpad click fix would be sweet, but 'just' a fix for the mouse pad and touch click thing would be nice too.
Lazarus is offline   Reply With Quote
Old 08-01-2015, 07:22 PM   #2
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,252
Default

mouse handling is tricky...

look at schwa / spk77's stuff. http://forum.cockos.com/showthread.php?t=161557


touchpads might be even trickier...

I'm not set up to test at the moment, but I do wonder if one of my own mouse handling schemes would work and be consistent enough.

in EEL:

Code:
//click areas must not overlap. to have an overlaping area use _instance version (or rename this function per function basis)


function mouse_click(cap)local(i) 
  (mouse_cap == cap ? i+=1: i=0; i == 1 ? 1 : 0;);

function _mouse_click(cap)instance(i) 
  (mouse_cap == cap ? i+=1: i=0; i == 1 ? 1 : 0;);


function mouse_in_rect(x,y,w,h)//return 1 if yes, 0 if no
  (  mouse_x > x && mouse_x < (x+w) && mouse_y > y && mouse_y < (y+h)  ? 1 : 0; );
this is fantastic for toggles, etc. you don't even have to track the mouse. it only breaks if something overlaps. (then just use the instance version - or re name it with a new name to be used within a specific function.)

so you just use it like...
Code:
mouse_in_rect(x,y,w,h) && mouse_click(1) ?  (do something);

Last edited by James HE; 08-01-2015 at 07:29 PM.
James HE is offline   Reply With Quote
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
Old 06-09-2017, 12:30 PM   #4
Airal
Human being with feelings
 
Join Date: Nov 2015
Posts: 376
Default

I'm having a similar problem I think. Seems mouse_cap stops working with modifiers when my script loses focus then comes back.

So, basically in my gui, at the start, everything works. But if I click, say the mute button of a track, then go back to my gui, none of the modifiers work(well, at least the shift doesn't work).

Seems to be a bug in reaper.
Airal is offline   Reply With Quote
Old 06-09-2017, 02:53 PM   #5
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,212
Default

Are you using a mouse or a touchpad/screen? I'm running cfillion's Keyboard Inspector right now and it doesn't have any trouble with losing focus + modifiers.

Edit: nm, saw your comment in another thread. Reaper doesn't give scripts any information about the keyboard/mouse when they're out of focus.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 06-11-2017, 09:25 AM   #6
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,451
Default

I'd update the thread (I used to be Lazarus, but rose again) but I locked myself out of that account. The issue of mousepad and touchscreen touches not registering (it actually took a double tap) was fixed a while after this was reported, I have no idea what version.
snooks is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.