Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 03-03-2019, 02:16 AM   #1
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default Left-Clicking on Ruler *breaks* Recall Edit Cursor Scripts

I was trying to program myself a pretty basic script last night just for optimizing workflow, but for some reason I found that Left-Clicking on the Ruler moves the Edit Cursor position, not graphically but internally, even with all of the Mouse Modifiers for 'Ruler' set to 'No Action.'

Let me give an example. I'm ​working a script that upon clicking on the Ruler, the Edit Cursor position is stored; the Edit Cursor is then moved to another location, an action is performed, and then lastly, the Edit Cursor is restored to its previous state.

The issue I'm having it is that every time I Left-Click on the Ruler the number that is stored is the Mouse Cursor position and not the Edit Cursor position, even though:

A. I have verified that I'm using the correct function, reaper.GetCursorPosition()

B. As previously mentioned, all Mouse Modifiers for the Ruler have been removed.

I would like to clarify that when I remove all the Mouse Modifiers for the Ruler and then Left-Click on the Ruler the Edit Cursor does not move. But for some reason the 'glitch' above still happens when trying to store and recall Edit Cursor position after having changed the Ruler, Left-Click Modified to activate my custom script.

Any help would be great

Last edited by Dafarkias; 03-03-2019 at 03:20 AM. Reason: clarification
Dafarkias is offline   Reply With Quote
Old 03-03-2019, 11:41 AM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

It would help if you post your script code. You can put it inside code tags to preserve indenting and make it more readable:

[code]
--your code here--
[/code]
__________________
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 03-03-2019, 01:23 PM   #3
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default Re

You're so right. My apologies. I've actually tried this several different ways since this post and each attempt I get the same result. I'll update this post after having created an example script of what I'm talking about.

Thanks!

Update:

K, I'm back.

Code:
reaper.ShowConsoleMsg("")
reaper.ShowConsoleMsg(reaper.GetCursorPosition().."\n"..reaper.BR_PositionAtMouseCursor(true))
All it takes for me to consistently reproduce this "glitch" is, for instance, to assign this script to Mouse Modifiers>Ruler>[Left-Click], and then click anywhere on the ruler. The following happens:



Strangely enough, if I press the spacebar to play after clicking on the ruler, the Edit Cursor and Play Cursor both jump to the position on the ruler that was clicked, instead of the playing for the residing location of the Edit Cursor.

Addendum:

Just FYI, it seems as if the functionality works in aspects that aren't contingent on the Ruler, E.G. my Toggle TrackViews#1&2 script uses this function (flawlessly as far as I can tell).

https://forum.cockos.com/showthread.php?t=217705
Attached Files
File Type: lua Dfk Edit Cursor Save&Recall Test.lua (125 Bytes, 148 views)

Last edited by Dafarkias; 03-03-2019 at 01:56 PM. Reason: Add info
Dafarkias is offline   Reply With Quote
Old 03-04-2019, 05:14 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

I can confirm that on 5.965. Moves the editcursor with single left-click, but doesn't with Alt+Shift+Leftclick(which I tested it with).

The code I used(which is slightly bugfixed from Dafarkias' code).

Code:
reaper.ShowConsoleMsg("")
window, segment, details = reaper.BR_GetMouseCursorContext()
reaper.ShowConsoleMsg(reaper.GetCursorPosition().."\n"..reaper.BR_PositionAtMouseCursor(true))
Windows 7, Reaper 5.965, SWS 2.10.0.1


@Dafarkias
To solve your script-problem, you should assume, that the editcursor-position has changed.
To force update of the new position of the editcursor, you could try running the two actions:

41044 - Move edit cursor forward one beat
and
41045 - Move edit cursor back one beat

You can also try it with SetEditCurPos or SetEditCurPos2:
https://mespotin.uber.space/Ultrasch...#SetEditCurPos
https://mespotin.uber.space/Ultrasch...SetEditCurPos2
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 03-04-2019, 05:57 AM   #5
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default Thanks!

Thanks mespotine, you are the goat!

Edit:

At work right now, haven't gotten to try your code yet, but just to clarify, this bug is preventing me from saving the edit cursor position before it being moved by clicking on the Ruler. I don't want the edit cursor to move until it's original position is recorded. But the code I presented proves that even with the Mouse Modifier>RulerLeftClick set to 'no action,' the edit cursor position updates to the mouse cursor position immediately (despite being scripted to perform 'no action').

Last edited by Dafarkias; 03-04-2019 at 06:21 AM. Reason: Edit
Dafarkias is offline   Reply With Quote
Old 03-04-2019, 07:12 AM   #6
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

reaper.UpdateTimeline() will force it to redraw, that might do the trick.
__________________
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 03-04-2019, 07:39 AM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Quote:
Originally Posted by Dafarkias View Post
Thanks mespotine, you are the goat!

Edit:

At work right now, haven't gotten to try your code yet, but just to clarify, this bug is preventing me from saving the edit cursor position before it being moved by clicking on the Ruler. I don't want the edit cursor to move until it's original position is recorded. But the code I presented proves that even with the Mouse Modifier>RulerLeftClick set to 'no action,' the edit cursor position updates to the mouse cursor position immediately (despite being scripted to perform 'no action').
Not possible that way, as Reaper changes the editcursorposition before running the script. This was also a problem for me in one usecase, so I added stuff to my Ultraschall-API to return the old editcursorposition before the current one.

Just install it and read this chapter on how to do it.

https://mespotin.uber.space/Mespotin...1_Introduction


If you have further questions about that, feel free to ask them in this thread about my Ultraschall-API: https://forum.cockos.com/showthread.php?t=214539
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 03-04-2019, 10:10 AM   #8
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default Re

Quote:
Originally Posted by mespotine View Post
Not possible that way, as Reaper changes the editcursorposition before running the script. This was also a problem for me in one usecase, so I added stuff to my Ultraschall-API to return the old editcursorposition before the current one.

Just install it and read this chapter on how to do it.

https://mespotin.uber.space/Mespotin...1_Introduction


If you have further questions about that, feel free to ask them in this thread about my Ultraschall-API: https://forum.cockos.com/showthread.php?t=214539
Wow. That is uncanny. You are awesome-sauce.

Edit:

Now I'm getting weird results with this script:
Code:
dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
reaper.ShowConsoleMsg("")
reaper.ShowConsoleMsg("Ultra: "..ultraschall.GetLastCursorPosition().."\n".."Mouse: "..reaper.BR_PositionAtMouseCursor(true))
The numbers are not staying true as I click in different segments of the Ruler, instead they are very similar, here are some results I've gotten clicking on the Ruler, with this script set as the action for MouseModifier>Ruler>LeftClick:

Ultra: 189.0915
Mouse: 183.06073322194

Ultra: 29.091
Mouse: 32.683804729754

Ultra: 126.061
Mouse: 134.97782818682

Keep in mind, I'm clicking in alternate locations on the ruler very far away from each other, the variances should be over a 100...

Last edited by Dafarkias; 03-04-2019 at 10:55 AM. Reason: Edit
Dafarkias is offline   Reply With Quote
Old 03-05-2019, 12:39 AM   #9
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Going to check it. Which Windows and Reaper version do you use?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 03-05-2019, 07:40 AM   #10
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default Reply

Windows 10, and 5.96, I believe. What I've seen after doing some more testing with the script, is your function that 'returns last edit cursor position,' is for some reason returning the previous position's, previous' position (<---not a typo)
Dafarkias is offline   Reply With Quote
Old 03-05-2019, 09:10 AM   #11
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Hmm...it should return the previous and current position.

I'll check that and fix it, as soon as possible.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 03-05-2019, 12:18 PM   #12
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Ok, it seems like the editcursor-position is changed twice, when using a modifier-key.

So usually it should be:
- Ultraschall-API sees, if the editcursorposition has changed and stores it in the background
- You use the GetlastCursorPosition()-function which returns the correct ones.

This works, when you put the script on a keyboard-shortcut.

But, when using the a modifier+mouseclick, it behaves like:
- Ultraschall-API sees, if the editcursorposition has changed and stores it in the background, but it is for some reason a wrong one
- You use the GetlastCursorPosition()-function which returns the wrong ones.
- Ultraschall-API sees, if the editcursorposition has changed again and stores it in the background, this time, the right one.

So this is a weird problem in Reaper that we can't fix, as far as I can say for now.

I try to find a simple way for the devs to replicate that, if it isn't a stupid bug on my side...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 03-05-2019, 01:56 PM   #13
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default Eureka!

I found a bug!
Dafarkias 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 05:51 PM.


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