|
|
|
03-03-2019, 02:16 AM
|
#1
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
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
|
|
|
03-03-2019, 11:41 AM
|
#2
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
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]
|
|
|
03-03-2019, 01:23 PM
|
#3
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
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
Last edited by Dafarkias; 03-03-2019 at 01:56 PM.
Reason: Add info
|
|
|
03-04-2019, 05:14 AM
|
#4
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
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
|
|
|
03-04-2019, 05:57 AM
|
#5
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
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
|
|
|
03-04-2019, 07:12 AM
|
#6
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
reaper.UpdateTimeline() will force it to redraw, that might do the trick.
|
|
|
03-04-2019, 07:39 AM
|
#7
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by Dafarkias
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
|
|
|
03-04-2019, 10:10 AM
|
#8
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Re
Quote:
Originally Posted by mespotine
|
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
|
|
|
03-05-2019, 12:39 AM
|
#9
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Going to check it. Which Windows and Reaper version do you use?
|
|
|
03-05-2019, 07:40 AM
|
#10
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
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)
|
|
|
03-05-2019, 09:10 AM
|
#11
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Hmm...it should return the previous and current position.
I'll check that and fix it, as soon as possible.
|
|
|
03-05-2019, 12:18 PM
|
#12
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
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...
|
|
|
03-05-2019, 01:56 PM
|
#13
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Eureka!
I found a bug!
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:51 PM.
|