Default Script
Default Script
How do I add a default script to a widget?
I tried manually adding a "Support" folder and a defaultscript.livecodescript file, but it did not get included.
I tried manually adding a "Support" folder and a defaultscript.livecodescript file, but it did not get included.
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- Livecode Staff Member
- Posts: 192
- Joined: Thu Apr 18, 2013 2:48 pm
Re: Default Script
support should be lowercase, although possibly that isn't the issue if you're on an os with a case insensitive file system.
Your default script stack needs to be named "your.widget.identifier.__DefaultScript", eg:
Other than that, the only reason I can think that it wouldn't work is a script parsing error in the default script...
Actually, what do you mean by 'didn't get included'?
Your default script stack needs to be named "your.widget.identifier.__DefaultScript", eg:
Code: Select all
script "com.livecode.widget.navbar.__DefaultScript"
Actually, what do you mean by 'didn't get included'?
Re: Default Script
by didn't get included, I meant that it didn't show up when I tested the widget and opened the script
the script is named:
and the widget is named:
do I need to include anything in the widget to look for the script's existence?
the script is named:
Code: Select all
script "community.livecode.madpink.buttonbar.__DefaultScript"
Code: Select all
widget community.livecode.madpink.buttonbar
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- Livecode Staff Member
- Posts: 192
- Joined: Thu Apr 18, 2013 2:48 pm
Re: Default Script
No, it should happen automatically. However, I'm wondering if there may be a docs issue here - we changed default scripts so that the handlers specified show up in the left hand side, rather than the script actually being automatically filled in - does your default script consist of (a) handler(s) and is its name not showing up in the default handler list?
Re: Default Script
Thus far I do have 1 handler and it is showing up on the handler list.
Also, changing the folder name to "support" did not help
Here is my widget so far if looking at helps:
https://github.com/madpink/buttonbar-livecode-builder
Also, changing the folder name to "support" did not help
Here is my widget so far if looking at helps:
https://github.com/madpink/buttonbar-livecode-builder
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- VIP Livecode Opensource Backer
- Posts: 4013
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Default Script
Greg,
your default script has some typos
this compiles
Kind regards
Bernd
your default script has some typos
this compiles
Code: Select all
on mouseUp
end mouseUp
--Sent if mType is "Action", need to add more cases as needed
on actionSelected
switch the buttonSelected of me
case 1
--Put Actions here
break
case 2
--Put Actions here
break
end switch
end actionSelected
function getSelected pDelim pType
local tData, tSelected
if pDelim is empty then put ";" into pDelim
if pType is empty then put "label" into pType
put the buttonData of me into tData
repeat for each key tKey in tData
if tData[tKey]["clicked"] then
if tSelected is not empty then
put pDelim after tSelected
end if
put tData[tKey][pType] after tSelected
end if
end repeat
return tSelected
end getSelected
Bernd
Re: Default Script
I did correct the script, but I still cannot get the default script to work
In fact, I grabbed the tree view widget off github and tried put it into the extension builder, and the default script doesn't show up there either... or is it possible that it doesn't work in "testing" mode?
In fact, I grabbed the tree view widget off github and tried put it into the extension builder, and the default script doesn't show up there either... or is it possible that it doesn't work in "testing" mode?
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Default Script
Setting a default script never worked correctly for me.
It is much easier to set a widget script in your widget in "OnOpen".
It is much easier to set a widget script in your widget in "OnOpen".
Code: Select all
public handler OnOpen()
...
post "if the script of me is empty then set script of me to " & myScript()
end handler
handler myScript () returns String
--> use \q for quote, \n for newline
end myScript
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 4013
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Default Script
the default script did not work for me either.
I resorted to make a button that sets the script.
but Hermann's solution might be easier.
Kind regards
Bernd
I resorted to make a button that sets the script.
but Hermann's solution might be easier.
Kind regards
Bernd
Re: Default Script
I think I like Hermann's approach better than using the default script as a separate file
Thanks both of you
Thanks both of you
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- Livecode Staff Member
- Posts: 192
- Joined: Thu Apr 18, 2013 2:48 pm
Re: Default Script
I'm still confused as to the specific issue here - if the handler shows up in the default handler list (and nothing else) then that is the expected behavior - we did away with default scripts actually populating the script, they merely define a list of handlers for the default handler list.
If I load the tree view with a new identifier I get the same as a tree view in the IDE, namely the four handlers in the left hand side as default handlers.
Although Hermann's method works, it might not always be possible to do such a thing and has different behavior from the other controls, plus you have to write your script with escaped characters - none of which strike me as easier - better to identify the bug if there is one and fix it (it's likely not a difficult fix). On the other hand, the current situation is not idea for what you want to do as I see your default handler is actually split into multiple handler definitions.
If I load the tree view with a new identifier I get the same as a tree view in the IDE, namely the four handlers in the left hand side as default handlers.
Although Hermann's method works, it might not always be possible to do such a thing and has different behavior from the other controls, plus you have to write your script with escaped characters - none of which strike me as easier - better to identify the bug if there is one and fix it (it's likely not a difficult fix). On the other hand, the current situation is not idea for what you want to do as I see your default handler is actually split into multiple handler definitions.
Re: Default Script
the confusion for me really started because I was remembering the default script that used to get populated for certain widgets, and all of the built-in widgets still have the defaultscript.livecodescript file with them. Didn't realize at that time that they were no longer being populated on purpose (really, just assumed I did something)
anyhow, I liked having the basic outline of a script
anyhow, I liked having the basic outline of a script
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
-
- Posts: 632
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Default Script
Just wanted to add a note here that HH's method to set a Widget's LCS script doesn't appear to work anymore (LC 9.6.1 Mac), it throws the error "LCB Error script access not allowed". Maybe this was changed for security reasons?[-hh] wrote: ↑Fri Aug 17, 2018 3:25 pmSetting a default script never worked correctly for me.
It is much easier to set a widget script in your widget in "OnOpen".
Code: Select all
public handler OnOpen() ... post "if the script of me is empty then set script of me to " & myScript() end handler handler myScript () returns String --> use \q for quote, \n for newline end myScript
Anyway the defaultscripts do work but they seem a bit tricky to get right. Ensure that your in-line lcdoc mark-up is working correctly or the default script won't show up.
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Default Script
I'm finding that the default script doesn't show up in the Extension Builder window ("No default script found") but if you click the Edit button the script does appear in the script editor and also populates the default script pane in the Extension Builder.
LC 9.6.1.
LC 9.6.1.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- Posts: 632
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Default Script
Yeah, the Extension Builder definitely needs some work:mwieder wrote: ↑Mon Sep 14, 2020 2:59 amI'm finding that the default script doesn't show up in the Extension Builder window ("No default script found") but if you click the Edit button the script does appear in the script editor and also populates the default script pane in the Extension Builder.
LC 9.6.1.
- I find the same problem with default script not showing in the window until clicking the edit script.
- My SVG icons do not replace or align with the default icon in the Builder window.
- I have to manually delete files in my project folder, clear the Documentation cache folder for my project in the RunRev folder, and quit/relaunch in order for documentation updates to show up in the dictionary.
- I sometimes have to manually delete build files in my project folder and quit/relaunch or the compile log shows "module already loaded" and then won't recompile.