Notifications
Clear all

[Closed] Parameter change label

Is it possible to change the text of a label after the rollout is already made? I’ve been using a parameter in a plugin and if the string changes it doesn’t seem to change the label. If not I’m assuming I would have to use a editText? Is there a good way to make the edit text look like the label rather than having a border and the text be selectable?
Thanks
D3Mi

12 Replies
4 Replies
(@gazybara)
Joined: 11 months ago

Posts: 0

Here are two examples. These are very similar but first not works and second works
#1

if isKindOf ::bgaRoll RolloutClass do destroyDialog bgaRoll
 rollout bgaRoll "test1"
 (
 	local lbl_capt = "spin_val:"
 	
 	label lbl "spin_val:" pos:[5,5] width:140
 	spinner spn "val:" pos:[5,25] fieldwidth:80
 	on spn changed val do lbl.text = (lbl.text + val as string) 
 
 )
 createDialog bgaRoll 150 50 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

#2

if isKindOf ::bgaRoll RolloutClass do destroyDialog bgaRoll
 rollout bgaRoll "test2"
 (
 	local lbl_capt = "spin_val:"
 	
 	label lbl lbl_capt pos:[5,5] width:140
 	spinner spn "val:" pos:[5,25] fieldwidth:80
 	on spn changed val do lbl.text = (lbl_capt + val as string) 
 
 )
 createDialog bgaRoll 150 50 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
(@denist)
Joined: 11 months ago

Posts: 0

possible… with some smart trick:

aa = attributes aa
(
	parameters params rollout:params
	(
		text type:#string ui:ui_text
		on text get val do if val != undefined do
		(
			this.params.lb_text.text = val
		)
	)
	rollout params "Params" 
	(
		edittext ui_text visible:off
		label lb_text offset:[0,-20]
		
		on params open do text
	)
)
delete objects
b = box isselected:on
custattributes.add b aa
b.text = "a test"
/*
b.text = "the test"
*/
(@gazybara)
Joined: 11 months ago

Posts: 0

on Open event is the key

(@denist)
Joined: 11 months ago

Posts: 0

there are three ‘keys’… ‘on open’ is only one of them

But wouldn’t the .text value reset if you were to click off the primitive and back on until you change the spinner?

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

Not understand you?

I’m using this in a simpleObject plugin. So I am creating a primitive geometric shape. If you were to try what you’re doing wouldn’t the rollout reset label if you clicked to another object and then back to the object with the label? Its not in a parameter of the object so its not stored anywhere correct?

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

I didn’t tried this in any plug but the changes of label text depends of spinner value.
So if spinner value is reset then will probaly affect on label.
Maybe is good also to add this in “on open do” event

try(destroyDialog ::bgaRoll)catch()
 rollout bgaRoll "• • •"
 (
 	local lbl_capt = "spin_val:"
 	
 	label lbl lbl_capt pos:[5,5] width:140
 	spinner spn "val:" pos:[5,25] fieldwidth:80
 	on spn changed val do lbl.text = (lbl_capt + val as string) 
 	on bgaRoll open do lbl.text = (lbl_capt + spn.value as string) 
 )
 createDialog bgaRoll 150 50 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

Okay thanks guys, thought maybe I was just using the param wrong. I got it working this way

it’s working only this way

Thought of another way and it works. I ended up just setting the text in definition of the UI to the param so when the rollout restarted it just added the param as the text. I.E.

	label currentShapeLb currentShapeName

currentShapeName being my changing param

… and you will redo (reload) your rollout every time when currentShapeName parameter changes.
i thought you’ve asked about how to link a parameter and a label control.