Ardem
July 29th, 2012, 13:48
I am having some trouble in making this work, and wondering if someone could point me in the right direction.
I have two different window class, one for the host and one for the client.
They access the same data from the db.xml.
The objective is a random weather creator.
On the client window class, I have an icon and read only fields. When the host runs the random generator it updates these fields. E.G rain, light breeze etc.
The icon on the client class should change when these fields change to one of the various picture s I have for weather.
It works on form open correctly, but I am unable to get the client to run the updateicon() code as it does not know there has been changes to the DB.
I thought in I had a OnUpdateChanged() in one of the fields activate it, however it does not seem to recognise there been a change even though its field has changed. Perhaps this is because of the host changing not the client window changing.
Here is some of the code that I have which work on form open but cannot get it to work on Fieldchange.
<genericcontrol name="icons">
<bounds>20,40,80,80</bounds>
<icon>icon_clearday</icon>
<script>
function updateicon()
if window.precipitation.getValue() == "Cloud Cover" then
window.icons.setIcon("icon_pcloudyday");
elseif window.precipitation.getValue() == "Patchy Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Drizzle" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Storm" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Torrential Rain" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Rain/Snow" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Patchy Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Snow" then
window.icons.setIcon("icon_snow");
elseif window.precipitation.getValue() == "Blizzard" then
window.icons.setIcon("icon_snow");
else
window.icons.setIcon("icon_clearday");
end
end
function onInit()
if super and super.onInit then
super.onInit();
end
updateicon();
end
</script>
</genericcontrol>
Code for the On open of the client form, this works putting in the correct icon.
<labeledstring name="precipitation"> <!-- PRECIPITATION- <anchored>
<to>title</to>
<position>insidetopleft</position>
<offset>80,20</offset>
<size>
<width>180</width>
<height>20</height>
</size>
</anchored>
<script>
function OnValueChanged()
if window.precipitation.getValue() == "Cloud Cover" then
window.icons.setIcon("icon_pcloudyday");
elseif window.precipitation.getValue() == "Patchy Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Drizzle" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Storm" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Torrential Rain" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Rain/Snow" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Patchy Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Snow" then
window.icons.setIcon("icon_snow");
elseif window.precipitation.getValue() == "Blizzard" then
window.icons.setIcon("icon_snow");
else
window.icons.setIcon("icon_clearday");
end
end
function onInit()
if super and super.onInit then
super.onInit();
end
OnValueChanged();
end
</script>
Code for one of the fields which change by the host entry, this does not seem to know there has been a change.
I have two different window class, one for the host and one for the client.
They access the same data from the db.xml.
The objective is a random weather creator.
On the client window class, I have an icon and read only fields. When the host runs the random generator it updates these fields. E.G rain, light breeze etc.
The icon on the client class should change when these fields change to one of the various picture s I have for weather.
It works on form open correctly, but I am unable to get the client to run the updateicon() code as it does not know there has been changes to the DB.
I thought in I had a OnUpdateChanged() in one of the fields activate it, however it does not seem to recognise there been a change even though its field has changed. Perhaps this is because of the host changing not the client window changing.
Here is some of the code that I have which work on form open but cannot get it to work on Fieldchange.
<genericcontrol name="icons">
<bounds>20,40,80,80</bounds>
<icon>icon_clearday</icon>
<script>
function updateicon()
if window.precipitation.getValue() == "Cloud Cover" then
window.icons.setIcon("icon_pcloudyday");
elseif window.precipitation.getValue() == "Patchy Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Drizzle" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Storm" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Torrential Rain" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Rain/Snow" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Patchy Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Snow" then
window.icons.setIcon("icon_snow");
elseif window.precipitation.getValue() == "Blizzard" then
window.icons.setIcon("icon_snow");
else
window.icons.setIcon("icon_clearday");
end
end
function onInit()
if super and super.onInit then
super.onInit();
end
updateicon();
end
</script>
</genericcontrol>
Code for the On open of the client form, this works putting in the correct icon.
<labeledstring name="precipitation"> <!-- PRECIPITATION- <anchored>
<to>title</to>
<position>insidetopleft</position>
<offset>80,20</offset>
<size>
<width>180</width>
<height>20</height>
</size>
</anchored>
<script>
function OnValueChanged()
if window.precipitation.getValue() == "Cloud Cover" then
window.icons.setIcon("icon_pcloudyday");
elseif window.precipitation.getValue() == "Patchy Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Drizzle" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Rain" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Storm" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Torrential Rain" then
window.icons.setIcon("icon_storm");
elseif window.precipitation.getValue() == "Rain/Snow" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Patchy Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Sleet" then
window.icons.setIcon("icon_rain");
elseif window.precipitation.getValue() == "Snow" then
window.icons.setIcon("icon_snow");
elseif window.precipitation.getValue() == "Blizzard" then
window.icons.setIcon("icon_snow");
else
window.icons.setIcon("icon_clearday");
end
end
function onInit()
if super and super.onInit then
super.onInit();
end
OnValueChanged();
end
</script>
Code for one of the fields which change by the host entry, this does not seem to know there has been a change.