Page 1 of 1

Open script file externally from ctb Edit dialog

Posted: 07 Aug 2022 07:17
by kiwichick
When using a custom toolbar button, more often than not, I'm loading a script file from one of the 'on click' fields as opposed to using multi-line script. But if I want to edit the script file, I have to open the button Edit dialog to see what the name of the script file is, close the Edit dialog, navigate to the script file and open it in a my text editor. What would be great is if there was the ability to open it in the text editor directly from the button Edit dialog (eg: a separate button, or maybe Ctrl-click on the Edit button). Would that be possible?

Re: Open script file externally from ctb Edit dialog

Posted: 08 Aug 2022 12:38
by admin
Difficult.

Re: Open script file externally from ctb Edit dialog

Posted: 08 Aug 2022 15:38
by LittleBiG
kiwichick wrote: 07 Aug 2022 07:17 When using a custom toolbar button, more often than not, I'm loading a script file from one of the 'on click' fields as opposed to using multi-line script. But if I want to edit the script file, I have to open the button Edit dialog to see what the name of the script file is, close the Edit dialog, navigate to the script file and open it in a my text editor. What would be great is if there was the ability to open it in the text editor directly from the button Edit dialog (eg: a separate button, or maybe Ctrl-click on the Edit button). Would that be possible?
There could be a workaround.
Put the script file into the CTB name, and you will be able to refer it as ctbname() in the button scripts.
Then you can load it in the left click and open it by the run command in the middle click event.
Like this:
2022-08-08_15h52_04.png

Re: Open script file externally from ctb Edit dialog

Posted: 09 Aug 2022 00:11
by kiwichick
admin wrote: 08 Aug 2022 12:38Difficult.
Thanks Don, :tup:

Re: Open script file externally from ctb Edit dialog

Posted: 09 Aug 2022 00:13
by kiwichick
LittleBiG wrote: 08 Aug 2022 15:38 There could be a workaround.
Thanks! What a neat idea. I'll definitely look into it.

UPDATE: I have my .xys files set to open in Notepad++ so all I needed to do was enter the open command for the script file into the click field. Easy peasy!

Code: Select all

open "<xyscripts>\MyScript.xys";
Of course, it does mean I sacrifice one of the click fields using this as a workaround but it's better than nothing, so thanks again.

Re: Open script file externally from ctb Edit dialog

Posted: 09 Aug 2022 07:58
by LittleBiG
If you don't want to sacrifice anything, use this kind of structure. Click runs the script, Ctrl+Click opens it.

Code: Select all

//leftscript
 $ctrl_pressed = get("shift") == 2;
   if ($ctrl_pressed) {
     open "<xyscripts>\MyScript.xys";
   }
   else {
     load "MyScript.xys";
   }

Re: Open script file externally from ctb Edit dialog

Posted: 11 Aug 2022 01:15
by kiwichick
LittleBiG wrote: 09 Aug 2022 07:58 If you don't want to sacrifice anything, use this kind of structure. Click runs the script, Ctrl+Click opens it.

Code: Select all

//leftscript
 $ctrl_pressed = get("shift") == 2;
   if ($ctrl_pressed) {
     open "<xyscripts>\MyScript.xys";
   }
   else {
     load "MyScript.xys";
   }
Oh my god, that is absolutely brilliant!!!!! I would never ever have thought of that. Thank you so much :appl: :appl: :appl: :appl: :appl: :appl: :appl: :appl: