Touch Toolbar helper

The next version of Aseprite v1.2.10-beta2 will contain scripting capabilities to show dialogs. This is a little example:

touch-toolbar

You can download this little script (Touch Toolbar.lua) and copy it in the scripting folder:

local dlg = Dialog("Touch Toolbar")
dlg
  :button{text="Undo",onclick=function() app.command.Undo() end}
  :button{text="Redo",onclick=function() app.command.Redo() end}
  :button{text="|<",onclick=function() app.command.GotoFirstFrame() end}
  :button{text="<",onclick=function() app.command.GotoPreviousFrame() end}
  :button{text=">",onclick=function() app.command.GotoNextFrame() end}
  :button{text=">|",onclick=function() app.command.GotoLastFrame() end}
  :button{text="+",onclick=function() app.command.NewFrame() end}
  :show{wait=false}

Then restart Aseprite and you will be able to open your toolbar from File > Scripts > Touch Toolbar:

52

6 Likes

I have to copy this code and paste in a wordpad?

Yes, and rename the *.txt extension of the text file in *.lua. And put it in the script folder (you can access it via File/Scripts/Open Scripts Folder).

1 Like

Thank you :slight_smile:

Hello, I would like to modify this script to make the bar only appear when I press a key and disappear when I press the key again.
I want the bar to appear right next to the cursor and I also want to customize the buttons to put the tools that I use, but that I don’t have in direct access with custom shortcuts.
Can I do that with the script.
Before I get into trouble I would like to know if it is possible.

The goal is to position the tools just within the cursor’s reach so you don’t have to move the cursor to the toolbar.

What if it were round instead of rectangular?
You press a key, the circle appears in the middle of the cursor with the custom tools, you choose a tool and then the circle disappears again.
Then you would have a bunch of quick access tools.
Shortcuts + circle of quick tools.
All to avoid moving the cursor to the side toolbars.

1


Hola, me gustaría modificar este script para hacer que la barra sólo aparezca cuando pulso alguna tecla y desaparezca cuando vuelvo a pulsar la tecla.
Quiero que la barra aparezca justo al lado del cursor y también quiero personalizar los botónes para poner las herramientas que uso, pero que no tengo en acceso directo con shortcuts personalizados.
¿Puedo hacer eso con el script?.
Antes de meterme al lío me gustaría saber si es posible.

El objetivo es ubicar las herramientas justo al alcance del cursor para no tener que desplazar el cursor hasta la barra lateral de herramientas.

¿Y si fuese redondo en vez de rectangular?.
Pulsas una tecla, aparece el círculo centrado con el curosr y con las herramientas personalizadas, eliges una herramienta y entonces el circulo desaparece nuevamente.
Entonces tendrías un montón de herramientas de rápido acceso.
Shortcuts + circulo de herramientas rápidas.
Todo para evitar desplazar el cursor a las barras de herramientas laterales.

1

4 Likes

hi, david, i’m making custom toolbar based on this example and i wanted to add option to run a script. i avoided app.command.RunScript and used dofile as you recommended here: Opening one script with another - #3 by dacap with just a file name.
when alone in script it works fine, but here in dialog, when i wrap dofile in a function, i get an error message: cannot open xxx.lua: No such file or directory. to run a script i have to insert absolute path like this:
:button{text="run",onclick=function() dofile( path .. 'xxx.lua') end}
i’d prefer not to do that, what is the correct way to use relative path here?

Hi @Olga_Galvanova, I’ll check this, the dofile('./other-file.lua') should work for relative names, but if it’s used from a function/callback used in a dialog that runs in the background, it might be a problem :thinking: if you can local object = dofile(...) at the header of your script and then using the object in the onclick callback, I think that might be the best solution at the moment.

(This is because the “current script path” is lost when we exit the script, but the dialog is still running)

2 Likes

thank you for an answer!
i’m still confused though, when i put local object = dofile(...) in my script, dofile is exectuted immediately.
on top of that when i use :button{text="run",onclick=object } it closes the script when i click the button, however if i use :button{text="run",onclick=function() object end} i get a syntax error. calling object() is attempt to call nil value, so i also tried
local f = assert(loadfile("./xxx.lua"))
f()
and nothing else in the script, because loadfile should return chunk as function, but i get No such file or directory error again. that same file which is executed by dofile perfectly fine.
so i’m completely lost now :]]

Oh sorry, maybe I didn’t explain in great detail :sweat_smile:

You can do something like this:

file1.lua (which defines a local function and returns it):

local function say_hi()
  app.alert "hi"
end
return say_hi

file2.lua (includes the other file, stores the function in its own local function, and then call the the function when the button is clicked):

local say_hi=dofile('./file1.lua')
Dialog()
  :button{ text="hi", onclick=say_hi }
  :show{ wait=false }
1 Like

oh, i understand now. this works, thank you!
but it would mean i have to duplicate all the scripts i want to use, so i guess sticking with absolute path is going to be easier for now :]]
but i’m sure this will be handy in the future.

I know this may not be the place for this, I’m starting to go crazy.

I don’t know if what I want to do is really hard or if I’m really stupid.

I’m trying to make a small modification to this same code.

I wanted to add a check box to minimize the window but it remains floating there, how do I do that, is there any command to minimize windows?

remembering that I would like to keep the window there, just minimize its size using a check box,

this toolbar has the same function I wanted

1 Like

Hi all! @dacap , please can you help me?

I installed the tool bar in this way, I just copy the code into a txt and rename to .lua, the script appear and run from Aseprite, but return an error.
Toolbar.lua:1: unexpected symbol near ‘{’

What I doing wrong?

Thank you very much for this incredible tool! I need this for iPAD too!

Hi @Leonardo_Amora, The content of the Toolbar.lua file should be exactly this: https://gist.githubusercontent.com/dacap/e470b917c343af38e84b81cb642b85d3/raw/f83d6b1f64a6fea5923ef52d1c6268a18b41ab1c/Touch%2520Toolbar.lua

Does the file looks just like that?

@dacap yes!

I’m on a Mac.