once again I need some help
This time it's about using Kt::Param in order to set up (like an) array of parameters that I can use later on to switch layers of widgets on and off and do other things (by script). As there are "other things", it's not done with just a few layers and display/undisplay them by param ... a bit complicated to explain the entire idea...
I got inspired by Ilias implementation of formulas_viewer
https://github.com/ilyaorlovru/plug-n-s ... ewer.kuiml
..and tried to follow it, but something is wrong and I can't find what.
The problem that i am facing is:
I CAN actually define an array of Kt::param in a Script section, but seemingly I have no access to it from within the script.
Here's the code ( VERY experimental and completely stripped down in order to show my problem, which is the ACCESS to the Kt::param array):
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<SKIN language_version="1.0" name="" margin="0" height="200" width="400">
<!-- MAIN PART -->
<EXPOSED_OBJECTS object_ids="" />
<SCRIPT requires="CB1_SVG1.display;CB1_SVG2.display" script="
array<Kt::Param@> highlight_params(2);
void highlightChord( int i)
{
CB1_SVG1.display = false;
CB1_SVG2.display = true;
highlight_params[1] = 1;
}
"/>
<STRING id="CHORD0" default="C" exposed="true"/>
<STRING id="CHORD1" default="Cm" exposed="true"/>
<STRING id="CHORD2" default="C°" exposed="true"/>
<STRING id="CHORD3" default="C+" exposed="true"/>
<TEMPLATE id="CHORDBOX" chordNum="-">
<PARAM id="$id$_backgroundColor" default="#00ff00"/>
<WIDGET id="$id$_WIDGET" layout_type="layer_stack">
<svg id="$id$_SVG1" width="40" height="40" viewBox="0 0 100 100" display="true"> <rect x="0" y="0" width="100%" height="100%" stroke="#ff0000" fill="#ff0000"/></svg>
<svg id="$id$_SVG2" width="40" height="40" viewBox="0 0 100 100" display="false"> <rect x="0" y="0" width="100%" height="100%" stroke="#00ff00" fill="#00ff00"/></svg>
<svg id="$id$_SVG3" width="40" height="40" viewBox="0 0 100 100" display="false"> <rect x="0" y="0" width="100%" height="100%" stroke="#0000ff" fill="#0000ff"/></svg>
<svg id="$id$_SVG4" width="40" height="40" viewBox="0 0 100 100" display="false"> <rect x="0" y="0" width="100%" height="100%" stroke="#ffff00" fill="#ffff00"/></svg>
<TEXT string_id="CHORD$chordNum$"/>
<PARAM id="$id$_mouseDown" name="$id$_mouseDown" type="boolean" default="false" exposed="true"/>
<INVISIBLE_PARAM_TOGGLE_SWITCH param_id="$id$_mouseDown" cursor="system::hand" width="100%" height="100%"/>
<ACTION_TRIGGER event_ids="$id$_mouseDown.value_changed" script="highlightChord(0);" requires=""/>
</WIDGET>
</TEMPLATE>
<!-- ..................................................................................................
LAYOUT
.................................................................................................. -->
<ROW spacing="10">
<COLUMN>
<WIDGET layout_type="layer_stack" >
<CHORDBOX id="CB1" chordNum="0"/>
</WIDGET>
<WIDGET layout_type="layer_stack" >
<CHORDBOX id="CB2" chordNum="1"/>
</WIDGET>
<WIDGET layout_type="layer_stack" >
<CHORDBOX id="CB3" chordNum="0"/>
</WIDGET>
</COLUMN>
</ROW>
</SKIN>
So, there is the define of the Kt::param array (as I understand it from Ilias example...an array with 2 Kt::Param):
array<Kt::Param@> highlight_params(2);
In highlightChord(..) I deactivate/activate two svg layers, just to visualise that the function gets actually called, for nothing else ..... It does, as one of the boxes becomes green when I click on a box (by ACTION_TRIGGER). Fine.
When I reverse the order in highlightChord(..) to
highlight_params[1] = 1;
CB1_SVG1.display = false;
CB1_SVG2.display = true;
nothing happens. Which seems to me, as if it stops working at highlight_params[1] = 1, which is my access to the highlight_params array. No errors showing up, it just ends here
So, there's something that I am doing wrong or a misunderstanding of concept, I don't know.
As far as I can see, the example accesses the Kt::Param array in exactly the same manner (see show_graph_a(..) and show_graph_b(..)).
Somebody can help me ?
Thanks.
Cheers
Rudi