PDA

View Full Version : Option filter in referenindex



montutur
June 8th, 2009, 22:23
Hi!
An option filter in referenceindex class, it is possible?
If it is possible, what is the solution?
Thanks in advance.

Montutur

Foen
June 9th, 2009, 05:45
Hi

Can you explain what you are after in a bit more detail?

Cheers

Foen

montutur
June 9th, 2009, 12:16
In library, we have a magnifying glass for research; this is the filter fonction in XML.
The same thing is it possible in the sheet referenceindex?

Montutur

Foen
June 9th, 2009, 12:22
I think this is possible in a custom ruleset: you'd need to edit the windowclass referenceindexcontent to add filter/filtertrigger controls and then edit the "index" windowlist definition in that windowclass to include an onFilter event handler.

Take a look at adventure_story.xml for examples of how these things are done in the encounterlist windowclass.

Cheers

Foen

montutur
June 11th, 2009, 04:02
Hi Foen
I make this code in blue and magnifying glass appear but research is not working.

<windowclass name="referenceindexitem">
<sizelimits>
<minimum>
<height>20</height>
</minimum>
</sizelimits>
<sheetdata>
<windowreferencefield name="listlink">
<bounds>0,0,20,20</bounds>
<icon>
<normal>button_openwindow</normal>
<pressed>button_emptytarget</pressed>
</icon>
<description>
<field>name</field>
</description>
</windowreferencefield>
<staticlinkstringfield name="name">
<bounds>25,4,-1,15</bounds>
<font>sheetlabel</font>
<linktarget>listlink</linktarget>
</staticlinkstringfield>
</sheetdata>
</windowclass>

<windowclass name="referenceindexcontent">
<sizelimits>
<minimum>
<height>20</height>
</minimum>
<maximum>
<height>10000</height>
</maximum>
</sizelimits>
<sheetdata>
<stringfield name="name">
<bounds>0,10,-1,20</bounds>
<font>sheetlabel</font>
<center />
<nodrag />
</stringfield>

<formattedtextfield name="description">
<anchored>
<to>name</to>
<position>below</position>
</anchored>
<font>
<normal>chatfont</normal>
<bold>narratorfont</bold>
<italic>chatitalicfont</italic>
<bolditalic>chatbolditalicfont</bolditalic>
<title>sheetlabel</title>
</font>
<linkicon>
<link>button_openwindow</link>
<emptylink>button_emptytarget</emptylink>
</linkicon>
<selectioncolor>#FFD296</selectioncolor>
<script>
function onInit()
if isEmpty() then
setVisible(false);
end
function onSortCompare(w1, w2)
return w1.name.getValue() &gt; w2.name.getValue();
end;

function onFilter(w)
local f = string.lower(window.filter.getValue());

if f == "" then
return true;
end

if string.find(string.lower(w.name.getValue()), f, 0, true) then
return true;
end

return false;
end
end
</script>
</formattedtextfield>

<windowlist name="index">
<anchored>
<to>description</to>
<position>below</position>
<right>
<parent>name</parent>
<anchor>right</anchor>
</right>
</anchored>
<datasource>.index</datasource>
<class>referenceindexitem</class>
<noscroll />
</windowlist>
</sheetdata>
</windowclass>

<windowclass name="referenceindex">
<frame>referencebox</frame>
<placement>
<size>
<width>350</width>
<height>450</height>
</size>
</placement>
<sizelimits>
<dynamic />
</sizelimits>
<minimize>minimized_reference</minimize>
<tooltip>
<field>name</field>
</tooltip>
<sheetdata>
<subwindow name="content">
<class>referenceindexcontent</class>
<bounds>20,9,-22,-14</bounds>
<activate />
</subwindow>
<scrollercontrol>
<anchored>
<to>content</to>
<position>insidebottomright</position>
</anchored>
<target>content</target>
<button>
<normal>button_scroller</normal>
<pressed>button_scroller_down</pressed>
</button>
</scrollercontrol>

<!-- apparition de la loupe -->
<filter name="filter">
<bounds>55,-50,-50,20</bounds>
<target>index</target>
<trigger>filtertrigger</trigger>
</filter>
<filtertrigger name="filtertrigger">
<bounds>-43,-83,21,41</bounds>
<target>filter</target>
</filtertrigger>
</sheetdata>
</windowclass>

Thanks
Montutur

Foen
June 11th, 2009, 05:53
The first section of blue code needs to go in a script section of the windowlist control called 'index', not the formattedtextfield.

Hopefully that should work for you.

Stuart

montutur
June 12th, 2009, 04:03
If i put the script at this place, in blue, an error message appear:

Script Error: [referenceindexcontent"]:1: attempt to index field 'filter' [a nil value]

<windowlist name="index">
<anchored>
<to>description</to>
<position>below</position>
<right>
<parent>name</parent>
<anchor>right</anchor>
</right>
</anchored>
<datasource>.index</datasource>
<class>referenceindexitem</class>
<noscroll />
<script>
function onSortCompare(w1, w2)
return w1.name.getValue() &gt; w2.name.getValue();
end;

function onFilter(w)
local f = string.lower(window.filter.getValue());

if f == "" then
return true;
end

if string.find(string.lower(w.name.getValue()), f, 0, true) then
return true;
end

return false;
end
</script>
</windowlist>
</sheetdata>
</windowclass>


Montutur

Foen
June 12th, 2009, 06:10
I think the second blue section (the filter and filtertrigger controls) needs to be just after the windowlist and before the closing </sheetdata> tag. The first bit of blue code does the actual filtering, but it needs to find the search text. The second bit of blue code provides the search text. The two pieces need to be in the same windowclass definition so they can link to each other.

Currently the filter and filter trigger are in referenceindex windowclass while the filtering code is in the referenceindexcontent windowclass, so they cannot easily link to each other (so the script error says the code cannot find the search text).

Hope that makes sense!

Stuart

montutur
June 13th, 2009, 03:19
No effect.
The problem is perhaps in the sript?
It's too difficult.
I abandon.

Montutur