[API] after moving cursor: re-reading cursor value often gives wrong position

Post Reply New Topic
RELATED
PRODUCTS

Post

Hi Moss, others,

I have fiddled around with Moss' Beatstep Pro script a little for educational purposes. My idea was to implement the following: When going into the Device mode, set the first device in the chain active. In the device mode, when navigating left/right within the chain, display the currently selected device name on the screen ('Device: polysynth' etc).

So I changed DeviceView.onActivate() as follows:

Code: Select all

public void onActivate ()
    {
        super.onActivate();
        this.model.getCursorDevice ().selectFirst ();
        logger.debug("activated, now selected: {}", this.model.getCursorDevice ().getPositionInChain());
    }
which brings me to the first issue: Most of the times I switch into the device view, the log line displays the wrong position (it's almost never 0 as I would expect). The behaviour within BWS however is correct (first device reliably selected).

I also guarded the CursorDevice.selectPrevious()/selectNext() call like this:

Code: Select all

    logger.debug("before left, now selected: {}", cd.getPositionInChain()); 
    cd.selectPrevious ();
    logger.debug("left, now selected: {}", cd.getPositionInChain());
And here I have the same issue: the behavior is correct (selection is moved along the device chain), but the 2nd position read after moving the cursor usually delivers the same value as before the change.

My suspicion is that all the cursor manipulation methods are executed asynchronously and thus the changes do not become visible immediately. Can you shed light on this? If I am correct, is there any way to handle this?

Thanks,
felix

Post Reply

Return to “Controller Scripting”