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: 169
- 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: 169
- 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: 3266
- 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: 1909
- 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: 3266
- 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: 169
- 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