Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Pre-Release Discussion

Reply
 
Thread Tools Display Modes
Old 07-07-2015, 01:55 AM   #521
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Quote:
Originally Posted by Xenakios View Post
Hmm, I have been at times suggested to use functions exported by the SWS plugin... However, now that I actually tried it for the first time with Lua ReaScript, it looks like that doesn't actually work. For example, the following fails with " 'reaper.SNM_AddReceive' is unknown" :

Code:
local src=reaper.GetTrack(0,0)
local dest=reaper.GetTrack(0,1)
reaper.SNM_AddReceive(src, dest, -1)
Am I using the function wrong or is Lua support missing from the SWS plugin, version 2.7.0 from May 2015? (I briefly looked at the SWS source code repository and no results were found when searching for "lua" in the source code. So I guess that answers my question, maybe...)
Yes, Lua/EEL function export (and anything related to REAPER 5) is only available in SWS pre-releases at the moment, e.g. SWS v2.7.1.
The same goes with the code, checkout the "next" branch...
Jeffos is offline   Reply With Quote
Old 07-07-2015, 10:33 AM   #522
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default IDE BUG REPORT

Bug Report:
Special characters such as ♪ are displayed as ? in the REAPER IDE.
I guess it is a font issue.
X-Raym is offline   Reply With Quote
Old 07-08-2015, 03:20 PM   #523
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Jeffos View Post
Yes, Lua/EEL function export (and anything related to REAPER 5) is only available in SWS pre-releases at the moment, e.g. SWS v2.7.1.
The same goes with the code, checkout the "next" branch...
Thanks. The test script works using the latest SWS build. It was kind of dumb of me not to check the other plugin source code branches...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 07-11-2015, 11:15 AM   #524
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Quote:
Originally Posted by planetnine View Post
Heyup fellas...
My main issue is I write in NP++ and after any saving in the IDE, my 4-space tabbed code gets converted to double-spaces (no tabs) -is there a way to prevent this happening?
A fix for that would be very welcome.

I really prefer tab, and any few scripts customization in REAPER IDE mess up all my indentations.

Thanks for listening !
X-Raym is offline   Reply With Quote
Old 07-15-2015, 05:05 PM   #525
Lazarus
Human being with feelings
 
Join Date: Aug 2013
Posts: 1,355
Default

Is everybody using this for their classes...
Code:
-- class.lua
-- Compatible with Lua 5.1 (not 5.0).
function class(base, init)
   local c = {}    -- a new class instance
   if not init and type(base) == 'function' then
      init = base
      base = nil
   elseif type(base) == 'table' then
    -- our new class is a shallow copy of the base class!
      for i,v in pairs(base) do
         c[i] = v
      end
      c._base = base
   end
   -- the class will be the metatable for all its objects,
   -- and they will look up their methods in it.
   c.__index = c

   -- expose a constructor which can be called by <classname>(<args>)
   local mt = {}
   mt.__call = function(class_tbl, ...)
   local obj = {}
   setmetatable(obj,c)
   if init then
      init(obj,...)
   else 
      -- make sure that any stuff from the base class is initialized!
      if base and base.init then
      base.init(obj, ...)
      end
   end
   return obj
   end
   c.init = init
   c.is_a = function(self, klass)
      local m = getmetatable(self)
      while m do 
         if m == klass then return true end
         m = m._base
      end
      return false
   end
   setmetatable(c, mt)
   return c
end
?

If so it might make sense if the file was bundled with Reaper with an include wildcard doodah already in the Lua path so we could just require("class") it. It's going to be duplicated so often either in separate files or files, making them a bit messy(er).

The prospect is giving me the heebie jeebies.

What do you think?
Lazarus is offline   Reply With Quote
Old 07-18-2015, 01:50 AM   #526
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Lazarus View Post

If so it might make sense if the file was bundled with Reaper with an include wildcard doodah already in the Lua path so we could just require("class") it. It's going to be duplicated so often either in separate files or files, making them a bit messy(er).

The prospect is giving me the heebie jeebies.

What do you think?
That's a good idea! Maybe some file and "table serialization" modules too.



EDIT: This is fixed

Bug report (EEL)
  • There is something wrong with gfx_triangle.
  • The polygon is not drawn to the screen without drawing something to the screen first.
  • gfx_triangle doesn't work from JSFX (should it )? JSFX editor seems to recognize the string "gfx_triangle"



Here's a test script:
EEL - draw polygon
Code:
// gfx window size
window_w = 400;
window_h = 400;
last_w = -1;
last_h = -1;

function on_gui_resize(w, h)
(
  gfx_set(1,1,0,1);
  // comment out next line -> the polygon is not drawn to the screen
  gfx_line(0,0,0,0); 

//               x       y
  gfx_triangle(w,      0.5*h,
               0.5*w,  h,
               0,      0.5*h,
               0.5*w,  0
               );
               
  last_w = gfx_w;
  last_h = gfx_h;
);

function run()
(
  gfx_w != last_w || gfx_h != last_h ? (
    on_gui_resize(gfx_w, gfx_h);
  );
  
  gfx_update();
  gfx_getchar() >= 0 ? defer("run();");
);

function init()
(
  gfx_init("", window_w, window_h);
  run();
);

init();

Last edited by spk77; 08-12-2015 at 11:14 AM.
spk77 is offline   Reply With Quote
Old 08-11-2015, 10:08 AM   #527
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Before v5 goes official, it would be nice if we could have back the ability to edit ReaScripts with another editor and not just native IDE.
Breeder is offline   Reply With Quote
Old 08-14-2015, 06:40 AM   #528
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by Breeder View Post
Before v5 goes official, it would be nice if we could have back the ability to edit ReaScripts with another editor and not just native IDE.
Am I the only one bothered by this? I know lots of us use either Sublime Text or Notepad++ for editing (nothing wrong with native IDE but it's kinda basic...)
Breeder is offline   Reply With Quote
Old 08-14-2015, 06:42 AM   #529
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Quote:
Originally Posted by Breeder View Post
Am I the only one bothered by this? I know lots of us use either Sublime Text or Notepad++ for editing (nothing wrong with native IDE but it's kinda basic...)
No, it annoys me quite a bit, too. It's nice that Cockos developed that native tool, but it doesn't replace Notepad++.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 08-14-2015, 07:17 AM   #530
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

+1 for breeder,

I like the native IDE, it is very efficient for debugging/creating JSFX, or customize a script quickly, or see meta infos (URL in comments are clickable !),
but for other kind of task, we may prefer a classic code editor
X-Raym is offline   Reply With Quote
Old 08-14-2015, 11:27 AM   #531
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Breeder View Post
it would be nice if we could have back the ability to edit ReaScripts with another editor and not just native IDE.
Yeah, the IDE is a big help but it's not a one stop editing shop. Mind you, I'd much rather see the IDE become powerful enough to make external editors useless...

Until then, perhaps a shift+click or something on the edit button to launch the external editor?
IXix is offline   Reply With Quote
Old 08-17-2015, 06:40 AM   #532
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Something that confuses a lot of Scripters Beginners is that the IDE Start button doesn't run the code that is displayed, but the last saved version of the script, so if you made any modification, they will not be take into account.
You have to save (CTRL+S) the script to make run in... But the lack of explicit Save Button confuses the user as well (I get several PM about that).

Proposition :
  • Replace Start Button by a Save and Run button
  • Add a Save button (without running the script).
of course, once we know the trick (we have to make CTRL+S) it is easy to overcome this problem, but that is not clear to scripts beginners.


Thanks for listening !
X-Raym is offline   Reply With Quote
Old 08-17-2015, 06:57 AM   #533
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Ahh, that explains a lot!
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 09-12-2015, 01:05 PM   #534
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,241
Default absolute coordinates

I was trying to display tooltips using the TrackCtl_SetToolTip function, around the mouse cursor gfx.mouse_x and gfx.mouse_y, or at gfx.x and gfx.y, but they are all relative to the window. MEaning that if the window is not at 0,0, the coordinates won't be right.

so the question is, how can we know the left and top coordinates of the UI script window? Thanks!
heda is offline   Reply With Quote
Old 09-12-2015, 11:55 PM   #535
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by heda View Post
so the question is, how can we know the left and top coordinates of the UI script window? Thanks!
Not possible
spk77 is offline   Reply With Quote
Old 09-13-2015, 02:25 AM   #536
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,241
Default

Quote:
Originally Posted by spk77 View Post
Not possible
I hope devs are reading and can fix this. please!
There must be a really big issue with this, for the same reason that we cannot gfx.init a window at some specific coordinates.
If getting the UI window coordinates is difficult, it would be good at least to have the absolute coordinates of the mouse cursor too. not relative to the gfx UI window. Thanks!
heda is offline   Reply With Quote
Old 09-13-2015, 03:59 AM   #537
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by heda View Post
I hope devs are reading and can fix this. please!
There must be a really big issue with this, for the same reason that we cannot gfx.init a window at some specific coordinates.
If getting the UI window coordinates is difficult, it would be good at least to have the absolute coordinates of the mouse cursor too. not relative to the gfx UI window. Thanks!
It would be awesome if get_action_context would return (last) mouse coordinates and mouse button states etc.
(It already returns the last mouse wheel value)
spk77 is offline   Reply With Quote
Old 09-13-2015, 07:39 AM   #538
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,926
Default

Quote:
Originally Posted by heda View Post
I hope devs are reading and can fix this. please!
There must be a really big issue with this, for the same reason that we cannot gfx.init a window at some specific coordinates.
If getting the UI window coordinates is difficult, it would be good at least to have the absolute coordinates of the mouse cursor too. not relative to the gfx UI window. Thanks!

+1 from me.

Especially now we can save data per project, reading and writing (via gfx_init) the window origin would be marvellous.

Current screen size too?



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-13-2015, 02:38 PM   #539
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,241
Default

Quote:
Originally Posted by planetnine View Post
+1 from me.

Especially now we can save data per project, reading and writing (via gfx_init) the window origin would be marvellous.

Current screen size too?



>
I agree with you.
But we need also to update the gfx.init function to support location of the floating window, not only width and height.
the window size is gfx.w and gfx.h but we need gfx.left and gfx.top or something like that, and to be able to gfx.init at a specific location.
heda is offline   Reply With Quote
Old 09-13-2015, 02:42 PM   #540
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

well you can dock the script, and store the dock state.

So, if you can isolate the window as the only thing in a floating dock, you can workaround it that way...

But %1000 - we need something to open at a particular location.
James HE is offline   Reply With Quote
Old 09-13-2015, 03:41 PM   #541
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Nitpick:

It would also look nice to see the little Reaper icon in the scripts that have graphics.
Here's a quick comparison.



__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 09-13-2015, 03:49 PM   #542
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,241
Default

Quote:
Originally Posted by WyattRice View Post
Nitpick:

It would also look nice to see the little Reaper icon in the scripts that have graphics.
I agree... or... why not a custom icon that we could define in the script's code?
heda is offline   Reply With Quote
Old 09-14-2015, 01:07 AM   #543
Lostz
Human being with feelings
 
Lostz's Avatar
 
Join Date: May 2012
Location: Italy - Austria
Posts: 55
Default

And the 'always in front' pin, please...
__________________
Thanks.
Lostz is offline   Reply With Quote
Old 09-14-2015, 03:19 PM   #544
snooks
Banned
 
Join Date: Sep 2015
Posts: 1,650
Default

Given this question its own thread...

http://forum.cockos.com/showthread.php?t=166494

Last edited by snooks; 09-16-2015 at 04:47 AM.
snooks is offline   Reply With Quote
Old 09-15-2015, 09:02 AM   #545
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,926
Default

Quote:
Originally Posted by Breeder View Post
Am I the only one bothered by this? I know lots of us use either Sublime Text or Notepad++ for editing (nothing wrong with native IDE but it's kinda basic...)

Is there no edited "REAPER version" of Lua for NP++? Do we just have to add the REAPER API commands to a text file? Have you got a text-file list of them at all Breeder?



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-15-2015, 11:59 AM   #546
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,241
Default

Quote:
Originally Posted by planetnine View Post
Is there no edited "REAPER version" of Lua for NP++? Do we just have to add the REAPER API commands to a text file? Have you got a text-file list of them at all Breeder?
>
this is my keyword list that you can import in the user defined language in Notepad++

https://stash.reaper.fm/25130/Lua%20REAPER.xml

maybe there are some new functions missing, but it's a start.
heda is offline   Reply With Quote
Old 09-15-2015, 01:59 PM   #547
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,926
Default

Thanks Heda -do I import it on top of the existing Lua language in NP++ ?



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 09-15-2015, 02:12 PM   #548
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,241
Default

Quote:
Originally Posted by planetnine View Post
Thanks Heda -do I import it on top of the existing Lua language in NP++ ?
>
sorry I think I didn't export the xml well. instead of importing user defined language, you cna use the already Lua style in Style configurator, and here is the list of functions for REAPER. You can paste it in the FUNC3 User defined keywords, in the Style Configurator window, in the Lua language.

https://stash.reaper.fm/25131/lua_REAPER.txt
heda is offline   Reply With Quote
Old 09-15-2015, 02:38 PM   #549
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,926
Default

That got it, thanks Heda.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 03-19-2016, 11:45 AM   #550
Jae.Thomas
Human being with feelings
 
Join Date: Jun 2006
Posts: 22,567
Default

Quote:
Originally Posted by spk77 View Post
Thanks, it worked!


Here's a very very messy and unfinished test version of "Take volume envelope manipulation" -script. It shouldn't crash anymore, so I thought I post it here for testing purposes:

https://stash.reaper.fm/24419/Manipul...e%20290615.zip

Quick instructions:
  • Add Manipulate take volume envelope 240615.lua to the action list
  • Select one mono take
  • Set time selection
  • Adjust sliders -> press 'create' (repeat if needed)
  • Optionally: Use compress/expand slider to compress or expand selected envelope points around midpoint
  • These might be better to set unticked:
    • Add edge points when moving envelope points and Envelope point selection follows time selection for the active envelope




It should look like this:




(There was even a messier version in the stash, but I removed it.)
compress/expand doesnt work here, it resets to 0
Jae.Thomas is offline   Reply With Quote
Old 03-20-2016, 04:40 AM   #551
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Quote:
Originally Posted by Jason Brian Merrill View Post
compress/expand doesnt work here, it resets to 0
I will have to check, but I think this script stopped working in a recent version of REAPER. Not sure why, though, but I couldn't get any joy out of it the other day either.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 05-08-2016, 05:48 PM   #552
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Hi,
Would anyone know if its possible in lua to get the input from a textbox like this, and put the input text in let's say a marker name with a enter keyboard event?
Quote:
Originally Posted by schwa View Post
Here is a basic text edit box in Lua, along with some generic mouse handling code. Super simple, no metamethods or anything, just a proof of concept.





Code:
gfx.init("Lua Sandbox",200,200)
reaper.atexit(gfx.quit)

BGCOL=0xFFFFFF

function setcolor(i)
  gfx.set(((i>>16)&0xFF)/0xFF, ((i>>8)&0xFF)/0xFF, (i&0xFF)/0xFF)
end


---- editbox ----

editbox={
  x=40, y=100, w=120, h=20, l=4, maxlen=12,
  fgcol=0x000000, fgfcol=0x00FF00, bgcol=0x808080,
  txtcol=0xFFFFFF, curscol=0x000000,
  font=1, fontsz=14, caret=0, sel=0, cursstate=0,
  text="", 
  hasfocus=false
}

function editbox_draw(e)
  setcolor(e.bgcol)
  gfx.rect(e.x,e.y,e.w,e.h,true)
  setcolor(e.hasfocus and e.fgfcol or e.fgcol)
  gfx.rect(e.x,e.y,e.w,e.h,false)
  gfx.setfont(e.font) 
  setcolor(e.txtcol)
  local w,h=gfx.measurestr(e.text)
  local ox,oy=e.x+e.l,e.y+(e.h-h)/2
  gfx.x,gfx.y=ox,oy
  gfx.drawstr(e.text)
  if e.sel ~= 0 then
    local sc,ec=e.caret,e.caret+e.sel
    if sc > ec then sc,ec=ec,sc end
    local sx=gfx.measurestr(string.sub(e.text, 0, sc))
    local ex=gfx.measurestr(string.sub(e.text, 0, ec))
    setcolor(e.txtcol)
    gfx.rect(ox+sx, oy, ex-sx, h, true)
    setcolor(e.bgcol)
    gfx.x,gfx.y=ox+sx,oy
    gfx.drawstr(string.sub(e.text, sc+1, ec))
  end 
  if e.hasfocus then
    if e.cursstate < 8 then   
      w=gfx.measurestr(string.sub(e.text, 0, e.caret))    
      setcolor(e.curscol)
      gfx.line(e.x+e.l+w, e.y+2, e.x+e.l+w, e.y+e.h-4)
    end
    e.cursstate=(e.cursstate+1)%16
  end
end

function editbox_getcaret(e)
  local len=string.len(e.text)
  for i=1,len do
    w=gfx.measurestr(string.sub(e.text,1,i))
    if gfx.mouse_x < e.x+e.l+w then return i-1 end
  end
  return len
end

function editbox_onmousedown(e)
  e.hasfocus=
    gfx.mouse_x >= editbox.x and gfx.mouse_x < editbox.x+editbox.w and
    gfx.mouse_y >= editbox.y and gfx.mouse_y < editbox.y+editbox.h    
  if e.hasfocus then
    e.caret=editbox_getcaret(e) 
    e.cursstate=0
  end
  e.sel=0 
end

function editbox_onmousedoubleclick(e)
  local len=string.len(e.text)
  e.caret=len ; e.sel=-len
end

function editbox_onmousemove(e)
  e.sel=editbox_getcaret(e)-e.caret
end

function editbox_onchar(e, c)
  if e.sel ~= 0 then
    local sc,ec=e.caret,e.caret+e.sel
    if sc > ec then sc,ec=ec,sc end
    e.text=string.sub(e.text,1,sc)..string.sub(e.text,ec+1)
    e.sel=0
  end
  if c == 0x6C656674 then -- left arrow
    if e.caret > 0 then e.caret=e.caret-1 end
  elseif c == 0x72676874 then -- right arrow
    if e.caret < string.len(e.text) then e.caret=e.caret+1 end
  elseif c == 8 then -- backspace
    if e.caret > 0 then 
      e.text=string.sub(e.text,1,e.caret-1)..string.sub(e.text,e.caret+1)
      e.caret=e.caret-1
    end
  elseif c >= 32 and c <= 125 and string.len(e.text) < e.maxlen then
    e.text=string.format("%s%c%s", 
      string.sub(e.text,1,e.caret), c, string.sub(e.text,e.caret+1))
    e.caret=e.caret+1
  end
end

---- generic mouse handling ----

mouse={}

function OnMouseDown()
  editbox_onmousedown(editbox)    
  mouse.down=true ; mouse.capcnt=0
  mouse.ox,mouse.oy=gfx.mouse_x,gfx.mouse_y
end

function OnMouseDoubleClick()
  if editbox.hasfocus then editbox_onmousedoubleclick(editbox) end
end

function OnMouseMove()
  if editbox.hasfocus then editbox_onmousemove(editbox) end  
  mouse.lx,mouse.ly=gfx.mouse_x,gfx.mouse_y
  mouse.capcnt=mouse.capcnt+1
end

function OnMouseUp()
  mouse.down=false
  mouse.uptime=os.clock()
end

---- runloop ----

function runloop()
  gfx.clear=BGCOL
   
  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
      
  local c=gfx.getchar()  
  if editbox.hasfocus then editbox_onchar(editbox, c) end  

  editbox_draw(editbox)

  gfx.update()  
  if c >= 0 and c ~= 27 then reaper.defer(runloop) end
end


gfx.setfont(1,"verdana",editbox.fontsz)

reaper.defer(runloop)
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 05-09-2016, 04:13 AM   #553
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Yes:

integer reaper.AddProjectMarker(ReaProject proj, boolean isrgn, number pos, number rgnend, string name, integer wantidx)
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 05-09-2016, 06:42 AM   #554
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Quote:
Originally Posted by Lokasenna View Post
Yes:

integer reaper.AddProjectMarker(ReaProject proj, boolean isrgn, number pos, number rgnend, string name, integer wantidx)
Thanks for the reply.

I think I might have wrote the question the wrong way or something.

In schwa's example of the textbox, when I type something in, and press enter on the keyboard, how can I return that to output?

Thanks, Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 05-09-2016, 07:31 AM   #555
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

I might of figured it out, or at least this is working.

At the end of the editbox_onchar(e, c) function, I added:

Code:
  if c == 13 then  -- enter key pressed
    pos = reaper.GetCursorPosition()
    reaper.AddProjectMarker(0, false,  pos, 0, e.text, -1) 
  end
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 08-07-2016, 07:38 AM   #556
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Quote:
Originally Posted by heda View Post
I agree with you.
In fact, most of the scripts we have don't use keyboard shortcuts. So the default could be to just ignore the keys in the scripts. And in case you have one script that needs some keys, you can just set it to pass all keys to the script and be a setting that is remembered somewhere. Could be an easy method to implement.
Seems inappropriate to 'hardwire' keycommands into a script anyway!

Shouldn't there be a means to let the user do it via the action menu, so they know their script commands won't conflict with existing keycommands?

The whole stealing focus thing (while cleary sometimes necessary for VSTs that are not part of the reaper ecosystem) seems like a less than optimal approach for something that should be able to be made to co-exist happily with the host app.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 08-07-2016, 08:22 AM   #557
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,241
Default

Woodslanding, the focus issue is solved now with a function that we can call to focus on the arrange so the script can be nice not stealing the focus if not needed. But you need to have SWS installed. But better control on the focus would be nice, for example to focus to MIDI Editor etc.
heda is offline   Reply With Quote
Old 08-08-2016, 03:28 PM   #558
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Well, that's good. Is there a means to pass focus to your script if needed?

I still think a solution like I mentioned makes sense. However, I can live without keycommands in scripts myself.

Thanks!!!
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 11-18-2019, 02:20 AM   #559
Regisfofo
Human being with feelings
 
Regisfofo's Avatar
 
Join Date: Mar 2017
Location: France
Posts: 627
Default

Quote:
Originally Posted by Breeder View Post
Not really a place for this, but since we already started talking about it...almost done!


I just have to solve it for tempo envelope and then I'll push it to our GitHub for new SWS pre
Is this feature avalable now ? how do we activate it ?
Regisfofo is offline   Reply With Quote
Old 11-18-2019, 06:51 AM   #560
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by Regisfofo View Post
Is this feature avalable now ? how do we activate it ?
Maybe this action?
Code:
SWS/BR: Freehand draw envelope while snapping points to left side grid line (perform until shortcut released)
Edgemeal 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 08:52 AM.


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