[Solved] Help LUA: A button in floating window to jump Tracks in Patte

I’m building a tool and have the following question:

A function to jump between tracks in pattern editor through a button (or various buttons). The button is fixed in a floating window.

Code button ( with function “NavTracks_xxx()” ):

vb:button {
        text = "◄",
        id = "tracknav_lx1",
        tooltip = "tracknav_lx1",
        height = 30,
        width = "5%",
        notifier = function()dialog:NavTrack_left() end
      },
      vb:button {
        text = "►",
        id = "tracknav_rx2",
        tooltip = "Tracknav_rx2",
        height = 30,
        width = "5%",
        notifier = function()dialog:NavTrack_right() end
      },

In notifier, I need the code of the functionNavTrack_left(), jump to left of selected track in pattern editor, and**NavTrack_right()**jump to left of selected track in pattern editor.

function NavTrack_left()

  -- the function 01

end

function NavTrack_right()

  -- the function 02

end

This idea is very simple.But the problem is that the two buttons are always in the floating window,and I do not know the code to navigate through the pattern editor (in the index of tracks and groups) without abandoning the floating window.Click in the buttons and the selection jump of track or group.Also able to jump between multiple tracks (x2 or x4…) with more buttons.

Can you help me, please?

Thanks in advance!

I’m testing code inside the function, but the terminal always returns an error like this:

*** main.lua:5750: unknown property or function 'NavTrack_left' for an object of type 'Dialog'
*** stack traceback:
*** [C]: in function '_error'
*** [string "do..."]:48: in function <[string "do..."]:35>
*** main.lua:5750: in function <main.lua:5750>

Can you help me, please?

Thanks in advance!

Hi Raul, you’ve really been smitted by the lua bug, eh? :slight_smile:

The error message gives you a little clue. It complains that an objectof type Dialog does not contain that property or function.

My guess is that you’ve created a dialog and named it, well, dialog?

dialog = renoise.app():show_custom_dialog(etc,blabla)

So, now the dialog variable is referring to a ViewBuilderDialog object.

And the problem is that you can’t just extend a Dialog object with whatever methods and properties you want. In fact, you can’t extend the built-in API objects_whatsoever_.

I can see the rationale behind your code: since the dialog contains the buttons, why not associate the methods with the dialog as well?

But, that’s simply not allowed because the Dialog is a C++ object with lua bindings, and you can’t just redefine that as you please.

Instead, what you want to do is simply to call plain functions in your tool. Just remove the “dialog:” part from the notifiers and it should work?

I’m learning many things suddenly on the LUA code.What I do is to use already built codes to see how they work, and trial and error.But sometimes, I can not fix some things.With small codes I can build bigger things.This is an example.

I understand your explanation… I know that something happens with "dialog"but I do not know how to fix it. I will try to test with the code you provided me.

If I can build, I will comment here… :slight_smile:

Thanks for the help!!!

Solved!!!

I’ve done what you’ve told me. Remove “dialog” and ready. Supreme stupidity…

Wonderful!!! ^^ ^^ ^^ ^^

I could build anything that I have proposed. Thank you very much for a little help.You may think it’s a foolishness. But you help a lot with these little doubts. You save a lot of time developer.

Thaaanks!!!