PDA

View Full Version : where does the control's update(bReadOnly, bForceHide) end up?



Varsuuk
January 21st, 2020, 03:02
I was clicking through the refdoc page trying to find where this call ends up. I looked up self in Lua docs but it was describing the syntactic sugar of implied arguments and some other uses - none of these seem to apply here.

So I suspect it is simply some global reference to the context, a this of sorts. Going by that, it is calling update() on the string_columnh which goes to basic_string etc.
But where do I find it? My trail ended at "stringcontrol" and the wiki does not refer to update on it or it's "parents", neither could I find it in the CoreRPG code.

I am not sure how to trace this... in C++/Java I'd run a blasted debugger ;)

I was just trying to verify what "self" means here (think I did - refers to the enclosing windowless and the lookup is to get at one of its controls - but now that think know that, can't find what update() does or even a comment on it.)


From npc_main.lua in 2E but is basically the same in 5E.


function updateControl(sControl, bReadOnly, bForceHide)
if not self[sControl] then
return false;
end

return self[sControl].update(bReadOnly, bForceHide);
end

Moon Wizard
January 21st, 2020, 04:53
The update function is part of several templates included in CoreRPG layer. (They are used heavily in column_ft, column_list, column_number, column_string templates; as well as update being a common name used in many templates and scripts)

Regards,
JPG

Varsuuk
January 21st, 2020, 05:12
The update function is part of several templates included in CoreRPG layer. (They are used heavily in column_ft, column_list, column_number, column_string templates; as well as update being a common name used in many templates and scripts)

Regards,
JPG

AH perfect, there it is - I missed how it got there. Now that know the end source, I am sure I will see the obvious connection back up the chain that I overlooked. thanks!


Now I can read to understand what the result bool means as well as how readonly and forcehide flags interact to get result.


function update(bReadOnly, bForceHide)
local bLocalShow;
if bForceHide then
bLocalShow = false;
else
bLocalShow = true;
if bReadOnly and not nohide and isEmpty() then
bLocalShow = false;
end
end

setReadOnly(bReadOnly);
setVisible(bLocalShow);

local sLabel = getName() .. "_label";
if window[sLabel] then
window[sLabel].setVisible(bLocalShow);
end
if separator then
if window[separator[1]] then
window[separator[1]].setVisible(bLocalShow);
end
end

if self.onVisUpdate then
self.onVisUpdate(bLocalShow, bReadOnly);
end

return bLocalShow;
end