View Full Version : <onclick> tags fillable using SkinSetting strings?
i was hoping it could be possible to set up dynamic <onclick> tags. i was thinking that would look like this:
<onclick>skin.string(button1label)</onclick>
where that string resolves to something like activatewindow(myprograms) for example.
devs, any comments?
jmarshall
2006-06-10, 01:04
i don't have time to look at it, but please feel free to do up a patch. you probably just need to add deciphering of the label (using g_infomanager.parselabel()) to the part in capplication::onmessage() i think it is that executes the function.
cheers,
jonathan
i haven't yet gotten started on a "real" language like c++ :(
any chance i could con/bribe/beg one of the other devs into doing this? it's sort of a crucial feature on the current skinning project i am developing...
Nuka1195
2006-06-11, 21:53
i don't have time to look at it, but please feel free to do up a patch. *you probably just need to add deciphering of the label (using g_infomanager.parselabel()) to the part in capplication::onmessage() i think it is that executes the function.
cheers,
jonathan
i couldn't figure out a way to do this using the above.
what i did was in cguicontrolfactory::getmultiplestring while it's reading in the <onclick> values made a call to g_infomanager.translatestring() and g_infomanager.getlabel() to use the translated values.
i'm not sure if this is good or not, but it could be added for the <onfocus> event also.
bool cguicontrolfactory::getmultiplestring(const tixmlnode* prootnode, const char* strtag, vector<cstdstring>& vecstringvalue)
{
const tixmlnode* pnode = prootnode->firstchild(strtag);
if (!pnode) return false;
vecstringvalue.clear();
bool bfound = false;
cstdstring strtag2 = strtag;
cstdstring strvalue;
while (pnode)
{
const tixmlnode *pchild = pnode->firstchild();
if (pchild != null)
{
strvalue = pchild->value();
if (strtag2 == "onclick")
{
int ret = g_infomanager.translatestring(pchild->value());
if (ret >= skin_has_setting_start && ret <= skin_has_setting_end)
strvalue = g_infomanager.getlabel(ret);
}
vecstringvalue.push_back(strvalue);
bfound = true;
}
pnode = pnode->nextsibling(strtag);
}
return bfound;
}
jmarshall
2006-06-12, 00:27
trouble with that is it's only executed on window load, so if the string updates while the window is on screen it won't update it's function.
instead if the label is parsed during the onclick event (drops down to capplication::onmessage() i think) then it'll work immediately. and yeah, translatestring() followed by getlabel() is probably all that is needed - it's not likely that you'll want to use the multi-info stuff.
cheers,
jonathan
Nuka1195
2006-06-12, 00:35
alright, i found case gui_msg_execute: is this where it should be put?
edit: there are two places to put it in that block. i put it at the top and called setstringparam():
the other place if it would be better for speed sake, would be to put it in the else and have it's own call to cutil::isbuiltin() and cutil::execbuiltin().
// see if it is a user set string
int iinfolabel = g_infomanager.translatestring(message.getstringpar am().c_str());
if (iinfolabel >= skin_has_setting_start && iinfolabel <= skin_has_setting_end)
message.setstringparam(g_infomanager.getlabel(iinf olabel));
Nuka1195
2006-06-12, 03:12
patch 1504525 (http://sourceforge.net/tracker/index.php?func=detail&aid=1504525&group_id=87054&atid=581840)
holy crap, i love you guys! since this patch got in on the 11th, any idea if it made it into the t3ch build that just came out today?
Nuka1195
2006-06-12, 05:58
that's just the submission, the patch hasn't been accepted and it may not be.
thanks for the information
- 12-06-2006 added: [ 1504525 ] <onclick> tags fillable using skinsetting strings, thanks to nuka1195.