Welcome, Guest
Please Login or Register.    Lost Password?

Copygroup Text
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Copygroup Text
#24385
Copygroup Text 5 Months, 2 Weeks ago  
Can the text inside a copygroup be changed using script or is this just not possible?

I have:
<elements>
<bitmap id="one" file="images/one.png" />
<bitmap id="two" file="images/two.png" />
<bitmap id="square" file="images/square.png" frames="3" />
<font id="normal" facename="Arial" size="12" />
</elements>

<copygroup ...>
<image id="picture" element="one" ..>
<button id="button" .. action="Test(#SKIN#, #WINDOW#, #ID#)>
<text id="title" text="123" element="normal" ..>
</copygroup

When the user presses the button, the image and text is supposed to change.
My script is...

function Test(skin, window, id)
local pos = id:gsub("button", "")
Rainlendar_SetItemValue(window, "picture" ..pos, "element", "two")
Rainlendar_SetItemValue(window, "text" ..pos, "text", "456")
end

The picture changes, the text does not. Am I doing something wrong?
SereneSavage
Junior Boarder
Posts: 31
graphgraph
User Offline Click here to see the profile of this user
Gender: Female Location: Canada
The administrator has disabled public write access.
 
#24386
Re: Copygroup Text 5 Months, 2 Weeks ago  
The "base id" of your text element is "title" in the skin.
But in your script, you're using "text" as base string for the id.
BigMike
Fresh Boarder
Posts: 18
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#24388
Re: Copygroup Text 5 Months, 2 Weeks ago  
Good catch. But no, that's just a typo from when I copied and pasted into this message.
Actually I've tried it several different ways including using bitmap fonts and I cannot get the text to change no matter what. I'm wondering if there is some special way I need to set it, before or after a refresh, or if the copygroup program only deals with images and ignores text.
If anyone can change text inside a copygroup I'd love to know how you did it.
SereneSavage
Junior Boarder
Posts: 31
graphgraph
User Offline Click here to see the profile of this user
Gender: Female Location: Canada
The administrator has disabled public write access.
 
#24389
Re:Copygroup Text 5 Months, 2 Weeks ago  
Ok, I see the problem, but I don't know how to solve it :'(

For the text change, you would probably need to call "Rainlendar_Redraw", but this recreates the copy group and therefore undos the changes of your script.

So with my test code, you can see:
- Without "Rainlendar_Redraw" clicking on the "Reload" button changes the text from old to new and clicking again, the text stays "new" (but isn't displayed as you noticed)
- With "Rainlendar_Redraw" clicking on the "Reload" button produces a text change from "old" to "new" every time (so Rainlendar_Redraw recreates the copygroup which resets the changes by the script)

My test code:
Code:

<copygroup id="copygrp" x="0" y="0" w="380" h="200" ycount="3">
<image id="pic" x="0" y="#YCOUNT#*50+10" element="bitmap.icon.weather.na" />
<button id="btn" x="50" y="#YCOUNT#*50+25" element="bitmap.button.reload" action="Test(#SKIN#, #WINDOW#, #ID#)" /> 
<text id="txt" x="70" y="#YCOUNT#*50+25" h="20" w="200" text="old" element="font.normal" /> 
</copygroup>



Code:

function Test(skin, window, id)
pos = id:gsub("btn", "")

bmp = Rainlendar_GetItemValue(window, "pic" .. pos, "element")
txt = Rainlendar_GetItemValue(window, "txt" .. pos, "text")
Rainlendar_Log(window .. " - " .. "pic" .. pos .. " " .. bmp)
Rainlendar_Log(window .. " - " .. "txt" .. pos .. " " .. txt)

Rainlendar_SetItemValue(window, "pic" .. pos, "element", "bitmap.icon.weather.1")
Rainlendar_SetItemValue(window, "txt" .. pos, "text", "new")

bmp = Rainlendar_GetItemValue(window, "pic" .. pos, "element")
txt = Rainlendar_GetItemValue(window, "txt" .. pos, "text")
Rainlendar_Log(window .. " - " .. "pic" .. pos .. " " .. bmp)
Rainlendar_Log(window .. " - " .. "txt" .. pos .. " " .. txt)
Rainlendar_Log(" -------------- ")

-- Rainlendar_Redraw(0, window)

end

BigMike
Fresh Boarder
Posts: 18
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2017/06/05 12:51 By BigMike.
The administrator has disabled public write access.
 
#24391
Re:Copygroup Text 5 Months, 2 Weeks ago  
Right. Picture change is displayed, new text is not (when not using Redraw).
I was wondering if <text> and <copygroup> were incompatible with each other, but then I look at the grid calendar which uses copygroup and a bitmap font. Those day numbers can be changed and they display immediately. So how is it working and what do I need to do to achieve the same?

(Edit: I set a tooltip to the image. Changed the tooltip when I changed the image. Tooltip will not display new text either.)
SereneSavage
Junior Boarder
Posts: 31
graphgraph
User Offline Click here to see the profile of this user
Gender: Female Location: Canada
Last Edit: 2017/06/06 01:17 By SereneSavage.
The administrator has disabled public write access.
 
Go to topPage: 1
get the latest posts directly to your desktop