Access Vb:views Outside Local Function

  
  
local vb;  
  
local close_button_row;  
  
function show_dialog()  
  
 close_button_row = vb:horizontal_aligner {  
 mode = "right",  
  
 vb:button {  
 id = "close"  
 text = "Close",  
 width = 60,  
 height = DEFAULT_DIALOG_BUTTON_HEIGHT,  
 notifier = function()  
 control_example_dialog:close()  
 end,  
 }  
 }  
  
end  
  
-- access by close_button_row var, this works  
close_button_row.text = "hello";  
  
-- access by vb var, this doesn't work  
vb.views.close.text = "hello";  
  
  

My question:

Is there any way to access the close button without instantiate a local variable outside show_dialog function ?

I’ve got a hunch that it might have to do with your function definition. It MIGHT work if you define your function local.

  
local function show_dialog()  
 --your code  
end  
  

The reasoning behind my (uneducated) hunch is that AFAIK ‘global’ functions are evaluated at runtime, whilst the local ones are evaluated before execution. Thus the view in question might not be present before the function actually runs for the first time. But this is purely speculation.

EDIT: scrap that. The same reasoning would make the close_button_row -pointer unavailable as well. Oh well.

forgot to mention, my function is already declared local.

Did you managed to call vb:[items] successfuly ?

I’ve not tried your provided code, but yes, I’ve accessed vb directly in some previous tool endeavours. And to I think I’ve used the similar method of defining id in the element (say, id=‘elementid’) and referring to it as vb.views.elementid.property_i_am_accessing.

Can’t say where the problem lies in your case…

Solved, there was a duplicate "local vb = " declaration inside show_dialog function…

Thank you

Tried:
vb.views[‘close’].text = “hello”
?
Another thing is:if the dialog is not formed yet, there won’t be anything to cast to either through the viewbuilder channel.
So the vb.views[‘id’].object=value will work if the dialog exists.