View Single Post
Old 03-21-2017, 04:21 AM   #57
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by ceanganb View Post
I guess I misunderstood the concept. What I want is to understand the path of an action since it's registered to the point it is executed, but it seems too techy too me.

But the action doesn't ´finish´, it's not released from memory when I run it again.
You will have to deal with the action toggle state(s) yourself.

So implement the action as a function/lambda like :

Code:
void MyAction(action_entry& ae)
{
	if (ae.m_togglestate == ToggleOff)
	{
		ae.m_togglestate = ToggleOn;
		ShowConsoleMsg("The action is on\n");
	}
	else
	{
		ae.m_togglestate = ToggleOff;
		ShowConsoleMsg("The action is off\n");
	}
}
If you have some custom state that needs to be allocated/deallocated etc, you will need to use global or static variables or the void* m_data member of the action_entry passed into the action function.

The toggle stuff doesn't currently report the toggle state back to Reaper, but that's just a visual thing anyway for the toolbar buttons and the action list. (I suppose I could add support for that... edit : Now added.)

Quote:
Originally Posted by ceanganb View Post
In your example, only the Window toggles its state. I do not understand how to exit from the action.
Hmm, I wonder if you are attempting something like this :
Code:
void MyAction(action_entry& ae)
{
  while (ae.m_togglestate == ToggleOn)
  {
     // do stuff
  }
}
That is most certainly not going to work. That would just hang the whole GUI thread (and Reaper) when the action is run. All the action handling stuff runs in the GUI thread. So if you do something like long or infinite loops at any point, that will be bad.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 03-21-2017 at 04:42 AM.
Xenakios is offline   Reply With Quote